Blame SOURCES/libvirt-qemu-hotplug-Use-typecasted-enum-in-qemuDomainDetachDeviceDiskLive.patch

99cbc7
From f77f23ddd733b005b989afbe6d28a6a7fdb88197 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <f77f23ddd733b005b989afbe6d28a6a7fdb88197@dist-git>
99cbc7
From: Peter Krempa <pkrempa@redhat.com>
99cbc7
Date: Thu, 11 Apr 2019 15:14:27 -0400
99cbc7
Subject: [PATCH] qemu: hotplug: Use typecasted enum in
99cbc7
 qemuDomainDetachDeviceDiskLive
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
Use the correct type in switch and populate the missing cases.
99cbc7
99cbc7
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
(cherry picked from commit afa15d78cba36e2c6c6d6ddc5c5258b7add405ba)
99cbc7
99cbc7
Partially-Resolves: https://bugzilla.redhat.com/1658198
99cbc7
Signed-off-by: Laine Stump <laine@redhat.com>
99cbc7
Signed-off-by: Laine Stump <laine@laine.org>
99cbc7
Message-Id: <20190411191453.24055-16-laine@redhat.com>
99cbc7
Acked-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_hotplug.c | 11 +++++++++--
99cbc7
 1 file changed, 9 insertions(+), 2 deletions(-)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
99cbc7
index 8047ac773f..b7db65964e 100644
99cbc7
--- a/src/qemu/qemu_hotplug.c
99cbc7
+++ b/src/qemu/qemu_hotplug.c
99cbc7
@@ -4820,7 +4820,7 @@ qemuDomainDetachDeviceDiskLive(virQEMUDriverPtr driver,
99cbc7
     }
99cbc7
     disk = vm->def->disks[idx];
99cbc7
 
99cbc7
-    switch (disk->device) {
99cbc7
+    switch ((virDomainDiskDevice) disk->device) {
99cbc7
     case VIR_DOMAIN_DISK_DEVICE_DISK:
99cbc7
     case VIR_DOMAIN_DISK_DEVICE_LUN:
99cbc7
         if (disk->bus == VIR_DOMAIN_DISK_BUS_VIRTIO)
99cbc7
@@ -4832,11 +4832,18 @@ qemuDomainDetachDeviceDiskLive(virQEMUDriverPtr driver,
99cbc7
             virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
99cbc7
                            _("This type of disk cannot be hot unplugged"));
99cbc7
         break;
99cbc7
-    default:
99cbc7
+
99cbc7
+    case VIR_DOMAIN_DISK_DEVICE_CDROM:
99cbc7
+    case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
99cbc7
         virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
99cbc7
                        _("disk device type '%s' cannot be detached"),
99cbc7
                        virDomainDiskDeviceTypeToString(disk->device));
99cbc7
         break;
99cbc7
+
99cbc7
+    case VIR_DOMAIN_DISK_DEVICE_LAST:
99cbc7
+    default:
99cbc7
+        virReportEnumRangeError(virDomainDiskDevice, disk->device);
99cbc7
+        break;
99cbc7
     }
99cbc7
 
99cbc7
     return -1;
99cbc7
-- 
99cbc7
2.21.0
99cbc7