From ed571d3ea264467c936fefc3452ce568ca31d77b Mon Sep 17 00:00:00 2001 From: Alex Lyn Date: Fri, 10 Jul 2026 10:46:09 +0800 Subject: [PATCH] runtime-rs: Drop legacy Block device path from Qemu The preceding "Use BlockConfigModern for ..." series converted every block-device producer in the Qemu path to emit BlockModern. The Qemu inner module still held the matching legacy Block consumer code across all three lifecycle ops (coldplug/hotplug/hotunplug), now unreachable. Remove it so BlockModern is the single code path, completing the BlockConfig -> BlockConfigModern migration at the Qemu layer. The hotunplug arm for Block now returns an explicit "unsupported" error instead of a stale QMP detach. The new added Block(_) is just a place holder and it will be removed in a follow-up commit. Signed-off-by: Alex Lyn --- .../crates/hypervisor/src/qemu/inner.rs | 96 +------------------ 1 file changed, 1 insertion(+), 95 deletions(-) diff --git a/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs b/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs index 66030d3ce0..28c43fccfb 100644 --- a/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs +++ b/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs @@ -187,41 +187,6 @@ impl QemuInner { } } } - DeviceType::Block(block_dev) => { - if block_dev.config.path_on_host == self.config.boot_info.initrd { - // If this block device represents initrd we ignore it here, it - // will be handled elsewhere by adding `-initrd` to the qemu - // command line. - continue; - } - match block_dev.config.driver_option.as_str() { - KATA_NVDIMM_DEV_TYPE => cmdline.add_nvdimm( - &block_dev.config.path_on_host, - block_dev.config.is_readonly, - )?, - KATA_CCW_DEV_TYPE | KATA_BLK_DEV_TYPE | KATA_SCSI_DEV_TYPE => { - let serial = if block_dev.config.serial_override.is_empty() { - None - } else { - Some(block_dev.config.serial_override.as_str()) - }; - cmdline.add_block_device( - block_dev.device_id.as_str(), - &block_dev.config.path_on_host, - block_dev - .config - .is_direct - .unwrap_or(self.config.blockdev_info.block_device_cache_direct), - block_dev.config.driver_option.as_str() == KATA_SCSI_DEV_TYPE, - block_dev.config.discard_unmap, - serial, - )? - } - unsupported => { - info!(sl!(), "unsupported block device driver: {}", unsupported) - } - } - } DeviceType::Network(network) => { // we need ensure add_network_device happens in netns. let _netns_guard = NetnsGuard::new(&netns).context("new netns guard")?; @@ -1037,7 +1002,6 @@ impl QemuInner { self.hotunplug_device(&device).await?; self.devices.retain(|d| match (d, &device) { - (DeviceType::Block(a), DeviceType::Block(b)) => a.config.index != b.config.index, (DeviceType::BlockModern(a), DeviceType::BlockModern(b)) => { !std::sync::Arc::ptr_eq(a, b) } @@ -1054,11 +1018,6 @@ impl QemuInner { }; match device { - DeviceType::Block(ref block_device) => { - let block_driver = &self.config.blockdev_info.block_device_driver; - qmp.hotunplug_block_device(block_driver, block_device.config.index) - .context("hotunplug block device")?; - } DeviceType::BlockModern(ref block_device) => { let (index, driver) = { let cfg = &block_device.lock().await.config; @@ -1079,6 +1038,7 @@ impl QemuInner { | DeviceType::HybridVsock(_) | DeviceType::Vsock(_) | DeviceType::Protection(_) + | DeviceType::Block(_) | DeviceType::PortDevice(_) => { return Err(anyhow!("hotunplug for {} is currently unsupported", device)); } @@ -1118,60 +1078,6 @@ impl QemuInner { return Ok(DeviceType::Network(network_device)); } - DeviceType::Block(mut block_device) => { - let block_driver = &self.config.blockdev_info.block_device_driver; - - // Determine iothread for hotplugged virtio-blk-pci devices. - // Only attach iothread when: - // 1. enable_iothreads is true - // 2. indep_iothreads > 0 - // 3. block driver is virtio-blk-pci - // 4. TODO: for more complex cases - let iothread = if self.config.enable_iothreads - && self.config.indep_iothreads > 0 - && block_driver == VIRTIO_BLK_PCI - { - // Use the first independent iothread (indep_iothread_0) - Some("indep_iothread_0") - } else { - None - }; - - let (pci_path, addr_str) = qmp - .hotplug_block_device( - block_driver, - block_device.config.index, - &block_device.config.path_on_host, - &block_device.config.blkdev_aio.to_string(), - Some( - block_device - .config - .is_direct - .unwrap_or(self.config.blockdev_info.block_device_cache_direct), - ), - block_device.config.is_readonly, - block_device.config.no_drop, - block_device.config.discard_unmap, - block_device.config.logical_sector_size, - block_device.config.physical_sector_size, - &block_device.config.format, - iothread, - ) - .context("hotplug block device")?; - - if pci_path.is_some() { - block_device.config.pci_path = pci_path; - } - if let Some(addr) = addr_str { - if block_driver == VIRTIO_BLK_CCW { - block_device.config.ccw_addr = Some(addr); - } else { - block_device.config.scsi_addr = Some(addr); - } - } - - return Ok(DeviceType::Block(block_device)); - } DeviceType::Vfio(mut vfiodev) => { // FIXME: the first one might not the true device we want to passthrough. // The `multifunction=on` is temporarily unsupported.