diff --git a/src/runtime-rs/crates/hypervisor/src/qemu/cmdline_generator.rs b/src/runtime-rs/crates/hypervisor/src/qemu/cmdline_generator.rs index 9e4668f0e7..7fc991d107 100644 --- a/src/runtime-rs/crates/hypervisor/src/qemu/cmdline_generator.rs +++ b/src/runtime-rs/crates/hypervisor/src/qemu/cmdline_generator.rs @@ -15,7 +15,7 @@ use std::borrow::Cow; use anyhow::{anyhow, Context, Result}; use async_trait::async_trait; -use kata_types::config::hypervisor::VIRTIO_SCSI; +use kata_types::config::hypervisor::{VIRTIO_BLK_PCI, VIRTIO_SCSI}; use kata_types::rootless::is_rootless; use serde::{Deserialize, Serialize}; use serde_json; @@ -2631,8 +2631,10 @@ impl<'a> QemuCmdLine<'a> { qemu_cmd_line.add_scsi_controller(); } - // Add independent IO threads for virtio-blk hotplug devices - qemu_cmd_line.add_indep_iothreads(); + // Add independent IO threads only when hotplug uses virtio-blk-pci. + if config.blockdev_info.block_device_driver == VIRTIO_BLK_PCI { + qemu_cmd_line.add_indep_iothreads(); + } if config.device_info.reclaim_guest_freed_memory { qemu_cmd_line.add_virtio_balloon(); @@ -2741,8 +2743,8 @@ impl<'a> QemuCmdLine<'a> { self.devices.push(Box::new(virtio_scsi)); } - /// Add independent IO threads for virtio-blk devices. - /// These threads can be attached to virtio-blk devices during hotplug. + /// Add independent IO threads for virtio-blk-pci devices. + /// These threads can be attached to virtio-blk-pci devices during hotplug. fn add_indep_iothreads(&mut self) { // Only create independent IO threads if enable_iothreads is true and indep_iothreads > 0 if self.config.enable_iothreads && self.config.indep_iothreads > 0 { diff --git a/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs b/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs index 87e1f40fd4..655de37d69 100644 --- a/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs +++ b/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs @@ -25,7 +25,7 @@ use anyhow::{anyhow, Context, Result}; use async_trait::async_trait; use kata_sys_util::netns::NetnsGuard; use kata_types::build_path; -use kata_types::config::hypervisor::{RootlessUser, VIRTIO_BLK_CCW}; +use kata_types::config::hypervisor::{RootlessUser, VIRTIO_BLK_CCW, VIRTIO_BLK_PCI}; use kata_types::rootless::is_rootless; use kata_types::{ capabilities::{Capabilities, CapabilityBits}, @@ -950,15 +950,15 @@ impl QemuInner { DeviceType::Block(mut block_device) => { let block_driver = &self.config.blockdev_info.block_device_driver; - // Determine iothread for virtio-blk devices + // 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 not virtio-scsi (i.e., it's virtio-blk) + // 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 != kata_types::config::hypervisor::VIRTIO_SCSI + && block_driver == VIRTIO_BLK_PCI { // Use the first independent iothread (indep_iothread_0) Some("indep_iothread_0") @@ -1066,6 +1066,7 @@ impl QemuInner { logical_sector_size, physical_sector_size, &BlockDeviceFormat::default(), + None, ) .context("hotplug block device")?;