The tests which match the disk bus to the controller type were backwards in this function. This meant that any disk bus type (such as VIR_DOMAIN_DISK_BUS_SATA) would not skip the controller index comparison even if the removed controller was of a different type. Switch the internals to a switch statement with selects the controller type in the first place and a proper type so that new controller types are added in the future. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1870072 Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_hotplug.c | 44 +++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 00d908912f..90ed59a0ee 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5327,16 +5327,48 @@ qemuDomainDiskControllerIsBusy(virDomainObjPtr vm, continue; /* check whether the disk uses this type controller */ - if (disk->bus == VIR_DOMAIN_DISK_BUS_IDE && - detach->type != VIR_DOMAIN_CONTROLLER_TYPE_IDE) + switch ((virDomainControllerType) detach->type) { + case VIR_DOMAIN_CONTROLLER_TYPE_IDE: + if (disk->bus != VIR_DOMAIN_DISK_BUS_IDE) + continue; + break; + + case VIR_DOMAIN_CONTROLLER_TYPE_FDC: + if (disk->bus != VIR_DOMAIN_DISK_BUS_FDC) + continue; + break; + + case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: + if (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI) + continue; + break; + + case VIR_DOMAIN_CONTROLLER_TYPE_SATA: + if (disk->bus != VIR_DOMAIN_DISK_BUS_SATA) + continue; + break; + + case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: + /* xenbus is not supported by the qemu driver */ continue; - if (disk->bus == VIR_DOMAIN_DISK_BUS_FDC && - detach->type != VIR_DOMAIN_CONTROLLER_TYPE_FDC) + + case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: + /* virtio-serial does not host any disks */ continue; - if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI && - detach->type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI) + + case VIR_DOMAIN_CONTROLLER_TYPE_CCID: + case VIR_DOMAIN_CONTROLLER_TYPE_USB: + case VIR_DOMAIN_CONTROLLER_TYPE_PCI: + case VIR_DOMAIN_CONTROLLER_TYPE_ISA: + /* These buses have (also) other device types too so they need to + * be checked elsewhere */ continue; + case VIR_DOMAIN_CONTROLLER_TYPE_LAST: + default: + continue; + } + if (disk->info.addr.drive.controller == detach->idx) return true; } -- 2.28.0