runtime: qemu: Add Independent IOThread support for virtio-blk

Make hotplug virtio-blk device attach to Independent IOThread 0 as default
when enabled the EnableIOThreads and IndepIOThreads.

Signed-off-by: zhangchen.kidd <zhangchen.kidd@jd.com>
This commit is contained in:
zhangchen.kidd 2025-06-16 21:03:36 +08:00
parent 1d273895b8
commit 6e677794ed

View File

@ -1744,7 +1744,13 @@ func (q *qemu) hotplugAddBlockDevice(ctx context.Context, drive *config.BlockDri
queues := int(q.config.NumVCPUs())
if err = q.qmpMonitorCh.qmp.ExecutePCIDeviceAdd(q.qmpMonitorCh.ctx, drive.ID, devID, driver, addr, bridge.ID, romFile, queues, true, defaultDisableModern, ""); err != nil {
// Make Independent IOThread 0 as the virtio-blk default.
var iothreadID string
if q.config.EnableIOThreads && q.config.IndepIOThreads > 0 {
iothreadID = fmt.Sprintf("%s_%d", indepIOThreadsPrefix, 0)
}
if err = q.qmpMonitorCh.qmp.ExecutePCIDeviceAdd(q.qmpMonitorCh.ctx, drive.ID, devID, driver, addr, bridge.ID, romFile, queues, true, defaultDisableModern, iothreadID); err != nil {
return err
}
case q.config.BlockDeviceDriver == config.VirtioBlockCCW: