1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

qemuDomainDiskControllerIsBusy: Fix logic of matching disk bus to controller type

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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2020-11-13 14:07:40 +01:00
parent a6d5a5712f
commit 022f4d431b

View File

@ -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;
}