Blame SOURCES/libvirt-qemu_hotplug-remove-extra-function-in-middle-of-DetachController-call-chain.patch

0a7476
From 2c69082662aaa4892434bcd16c764029f707ae0d Mon Sep 17 00:00:00 2001
0a7476
Message-Id: <2c69082662aaa4892434bcd16c764029f707ae0d@dist-git>
0a7476
From: Laine Stump <laine@laine.org>
0a7476
Date: Thu, 11 Apr 2019 15:14:41 -0400
0a7476
Subject: [PATCH] qemu_hotplug: remove extra function in middle of
0a7476
 DetachController call chain
0a7476
0a7476
qemuDomainDetachDeviceControllerLive() just checks if the controller
0a7476
type is SCSI, and then either returns failure, or calls
0a7476
qemuDomainDetachControllerDevice().
0a7476
0a7476
Instead, lets just check for type != SCSI at the top of the latter
0a7476
function, and call it directly.
0a7476
0a7476
Signed-off-by: Laine Stump <laine@laine.org>
0a7476
ACKed-by: Peter Krempa <pkrempa@redhat.com>
0a7476
(cherry picked from commit e4d96324b48b8aab864212382390a5c4a40970d2)
0a7476
0a7476
Partially-Resolves: https://bugzilla.redhat.com/1658198
0a7476
Signed-off-by: Laine Stump <laine@redhat.com>
0a7476
Signed-off-by: Laine Stump <laine@laine.org>
0a7476
Message-Id: <20190411191453.24055-30-laine@redhat.com>
0a7476
Acked-by: Michal Privoznik <mprivozn@redhat.com>
0a7476
---
0a7476
 src/qemu/qemu_hotplug.c | 30 ++++++++----------------------
0a7476
 1 file changed, 8 insertions(+), 22 deletions(-)
0a7476
0a7476
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
0a7476
index 930f8d3358..1b15116a9f 100644
0a7476
--- a/src/qemu/qemu_hotplug.c
0a7476
+++ b/src/qemu/qemu_hotplug.c
0a7476
@@ -4996,6 +4996,13 @@ int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver,
0a7476
     int idx, ret = -1;
0a7476
     virDomainControllerDefPtr detach = NULL;
0a7476
 
0a7476
+    if (dev->data.controller->type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
0a7476
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
0a7476
+                       _("'%s' controller cannot be hot unplugged."),
0a7476
+                       virDomainControllerTypeToString(dev->data.controller->type));
0a7476
+        return -1;
0a7476
+    }
0a7476
+
0a7476
     if ((idx = virDomainControllerFind(vm->def,
0a7476
                                        dev->data.controller->type,
0a7476
                                        dev->data.controller->idx)) < 0) {
0a7476
@@ -5638,27 +5645,6 @@ qemuDomainDetachLease(virQEMUDriverPtr driver,
0a7476
 }
0a7476
 
0a7476
 
0a7476
-static int
0a7476
-qemuDomainDetachDeviceControllerLive(virQEMUDriverPtr driver,
0a7476
-                                     virDomainObjPtr vm,
0a7476
-                                     virDomainDeviceDefPtr dev,
0a7476
-                                     bool async)
0a7476
-{
0a7476
-    virDomainControllerDefPtr cont = dev->data.controller;
0a7476
-    int ret = -1;
0a7476
-
0a7476
-    switch (cont->type) {
0a7476
-    case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
0a7476
-        ret = qemuDomainDetachControllerDevice(driver, vm, dev, async);
0a7476
-        break;
0a7476
-    default :
0a7476
-        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
0a7476
-                       _("'%s' controller cannot be hot unplugged."),
0a7476
-                       virDomainControllerTypeToString(cont->type));
0a7476
-    }
0a7476
-    return ret;
0a7476
-}
0a7476
-
0a7476
 int
0a7476
 qemuDomainDetachDeviceLive(virDomainObjPtr vm,
0a7476
                            virDomainDeviceDefPtr dev,
0a7476
@@ -5672,7 +5658,7 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
0a7476
         ret = qemuDomainDetachDeviceDiskLive(driver, vm, dev, async);
0a7476
         break;
0a7476
     case VIR_DOMAIN_DEVICE_CONTROLLER:
0a7476
-        ret = qemuDomainDetachDeviceControllerLive(driver, vm, dev, async);
0a7476
+        ret = qemuDomainDetachControllerDevice(driver, vm, dev, async);
0a7476
         break;
0a7476
     case VIR_DOMAIN_DEVICE_LEASE:
0a7476
         ret = qemuDomainDetachLease(driver, vm, dev->data.lease);
0a7476
-- 
0a7476
2.21.0
0a7476