From fab859d11f3951bb05b36fee71aa8a75d299d8c4 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 2 Feb 2016 10:09:33 +0100 Subject: [PATCH] qemu: hotplug: Break up if/else statement into switch --- src/qemu/qemu_hotplug.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 01010639fb..43f686c999 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -818,19 +818,31 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn, case VIR_DOMAIN_DISK_DEVICE_DISK: case VIR_DOMAIN_DISK_DEVICE_LUN: - if (disk->bus == VIR_DOMAIN_DISK_BUS_USB) { + switch ((virDomainDiskBus) disk->bus) { + case VIR_DOMAIN_DISK_BUS_USB: if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("disk device='lun' is not supported for usb bus")); break; } - ret = qemuDomainAttachUSBMassStorageDevice(conn, driver, vm, - disk); - } else if (disk->bus == VIR_DOMAIN_DISK_BUS_VIRTIO) { + ret = qemuDomainAttachUSBMassStorageDevice(conn, driver, vm, disk); + break; + + case VIR_DOMAIN_DISK_BUS_VIRTIO: ret = qemuDomainAttachVirtioDiskDevice(conn, driver, vm, disk); - } else if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) { + break; + + case VIR_DOMAIN_DISK_BUS_SCSI: ret = qemuDomainAttachSCSIDisk(conn, driver, vm, disk); - } else { + break; + + case VIR_DOMAIN_DISK_BUS_IDE: + case VIR_DOMAIN_DISK_BUS_FDC: + case VIR_DOMAIN_DISK_BUS_XEN: + 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_OPERATION_UNSUPPORTED, _("disk bus '%s' cannot be hotplugged."), virDomainDiskBusTypeToString(disk->bus)); -- GitLab