qemu: Use switch for qemuCheckIOThreads

Rather than an if statement, use a switch.

The switch will also catch the illegal usage of 'iothread' with some other
kind of unsupported bus configuration.
This commit is contained in:
John Ferlan 2016-04-18 07:39:59 -04:00
parent e0d0e53086
commit ade5dae282

View File

@ -1468,14 +1468,31 @@ qemuCheckIOThreads(const virDomainDef *def,
virDomainDiskDefPtr disk) virDomainDiskDefPtr disk)
{ {
/* Right "type" of disk" */ /* Right "type" of disk" */
if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO || switch ((virDomainDiskBus)disk->bus) {
(disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && case VIR_DOMAIN_DISK_BUS_VIRTIO:
disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) { if (disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
disk->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("IOThreads only available for virtio pci and " _("IOThreads only available for virtio pci and "
"virtio ccw disk")); "virtio ccw disk"));
return false; return false;
} }
break;
case VIR_DOMAIN_DISK_BUS_IDE:
case VIR_DOMAIN_DISK_BUS_FDC:
case VIR_DOMAIN_DISK_BUS_SCSI:
case VIR_DOMAIN_DISK_BUS_XEN:
case VIR_DOMAIN_DISK_BUS_USB:
case VIR_DOMAIN_DISK_BUS_UML:
case VIR_DOMAIN_DISK_BUS_SATA:
case VIR_DOMAIN_DISK_BUS_SD:
case VIR_DOMAIN_DISK_BUS_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("IOThreads not available for bus %s target %s"),
virDomainDiskBusTypeToString(disk->bus), disk->dst);
return false;
}
/* Can we find the disk iothread in the iothreadid list? */ /* Can we find the disk iothread in the iothreadid list? */
if (!virDomainIOThreadIDFind(def, disk->iothread)) { if (!virDomainIOThreadIDFind(def, disk->iothread)) {