Blame SOURCES/libvirt-qemu_hotplug-move-qemuDomainDetachDeviceLive-to-qemu_hotplug.c.patch

99cbc7
From 5d41ed96da86e3557eef2573d6973f56d43a8574 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <5d41ed96da86e3557eef2573d6973f56d43a8574@dist-git>
99cbc7
From: Laine Stump <laine@laine.org>
99cbc7
Date: Thu, 11 Apr 2019 15:14:40 -0400
99cbc7
Subject: [PATCH] qemu_hotplug: move qemuDomainDetachDeviceLive() to
99cbc7
 qemu_hotplug.c
99cbc7
99cbc7
This function is going to take on some of the functionality of its
99cbc7
subordinate functions, which all live in qemu_hotplug.c.
99cbc7
99cbc7
qemuDomainDetachDeviceControllerLive() is only called from
99cbc7
qemuDomainDetachDeviceLive() (and will soon be merged into
99cbc7
qemuDomainDetachControllerDevice(), which is in qemu_hotplug.c), so
99cbc7
it is also moved.
99cbc7
99cbc7
Signed-off-by: Laine Stump <laine@laine.org>
99cbc7
ACKed-by: Peter Krempa <pkrempa@redhat.com>
99cbc7
(cherry picked from commit 6a9c3fbade1d5479f4893a0f31293f13ad8bf229)
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-29-laine@redhat.com>
99cbc7
Acked-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_driver.c  | 95 ----------------------------------------
99cbc7
 src/qemu/qemu_hotplug.c | 97 +++++++++++++++++++++++++++++++++++++++++
99cbc7
 src/qemu/qemu_hotplug.h |  5 +++
99cbc7
 3 files changed, 102 insertions(+), 95 deletions(-)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
99cbc7
index 6ab1aa28c5..4cdc68a83a 100644
99cbc7
--- a/src/qemu/qemu_driver.c
99cbc7
+++ b/src/qemu/qemu_driver.c
99cbc7
@@ -7736,101 +7736,6 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm,
99cbc7
     return ret;
99cbc7
 }
99cbc7
 
99cbc7
-static int
99cbc7
-qemuDomainDetachDeviceControllerLive(virQEMUDriverPtr driver,
99cbc7
-                                     virDomainObjPtr vm,
99cbc7
-                                     virDomainDeviceDefPtr dev,
99cbc7
-                                     bool async)
99cbc7
-{
99cbc7
-    virDomainControllerDefPtr cont = dev->data.controller;
99cbc7
-    int ret = -1;
99cbc7
-
99cbc7
-    switch (cont->type) {
99cbc7
-    case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
99cbc7
-        ret = qemuDomainDetachControllerDevice(driver, vm, dev, async);
99cbc7
-        break;
99cbc7
-    default :
99cbc7
-        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
99cbc7
-                       _("'%s' controller cannot be hot unplugged."),
99cbc7
-                       virDomainControllerTypeToString(cont->type));
99cbc7
-    }
99cbc7
-    return ret;
99cbc7
-}
99cbc7
-
99cbc7
-static int
99cbc7
-qemuDomainDetachDeviceLive(virDomainObjPtr vm,
99cbc7
-                           virDomainDeviceDefPtr dev,
99cbc7
-                           virQEMUDriverPtr driver,
99cbc7
-                           bool async)
99cbc7
-{
99cbc7
-    int ret = -1;
99cbc7
-
99cbc7
-    switch ((virDomainDeviceType)dev->type) {
99cbc7
-    case VIR_DOMAIN_DEVICE_DISK:
99cbc7
-        ret = qemuDomainDetachDeviceDiskLive(driver, vm, dev, async);
99cbc7
-        break;
99cbc7
-    case VIR_DOMAIN_DEVICE_CONTROLLER:
99cbc7
-        ret = qemuDomainDetachDeviceControllerLive(driver, vm, dev, async);
99cbc7
-        break;
99cbc7
-    case VIR_DOMAIN_DEVICE_LEASE:
99cbc7
-        ret = qemuDomainDetachLease(driver, vm, dev->data.lease);
99cbc7
-        break;
99cbc7
-    case VIR_DOMAIN_DEVICE_NET:
99cbc7
-        ret = qemuDomainDetachNetDevice(driver, vm, dev, async);
99cbc7
-        break;
99cbc7
-    case VIR_DOMAIN_DEVICE_HOSTDEV:
99cbc7
-        ret = qemuDomainDetachHostDevice(driver, vm, dev, async);
99cbc7
-        break;
99cbc7
-    case VIR_DOMAIN_DEVICE_CHR:
99cbc7
-        ret = qemuDomainDetachChrDevice(driver, vm, dev->data.chr, async);
99cbc7
-        break;
99cbc7
-    case VIR_DOMAIN_DEVICE_RNG:
99cbc7
-        ret = qemuDomainDetachRNGDevice(driver, vm, dev->data.rng, async);
99cbc7
-        break;
99cbc7
-    case VIR_DOMAIN_DEVICE_MEMORY:
99cbc7
-        ret = qemuDomainDetachMemoryDevice(driver, vm, dev->data.memory, async);
99cbc7
-        break;
99cbc7
-    case VIR_DOMAIN_DEVICE_SHMEM:
99cbc7
-        ret = qemuDomainDetachShmemDevice(driver, vm, dev->data.shmem, async);
99cbc7
-        break;
99cbc7
-    case VIR_DOMAIN_DEVICE_WATCHDOG:
99cbc7
-        ret = qemuDomainDetachWatchdog(driver, vm, dev->data.watchdog, async);
99cbc7
-        break;
99cbc7
-    case VIR_DOMAIN_DEVICE_INPUT:
99cbc7
-        ret = qemuDomainDetachInputDevice(vm, dev->data.input, async);
99cbc7
-        break;
99cbc7
-    case VIR_DOMAIN_DEVICE_REDIRDEV:
99cbc7
-        ret = qemuDomainDetachRedirdevDevice(driver, vm, dev->data.redirdev, async);
99cbc7
-        break;
99cbc7
-
99cbc7
-    case VIR_DOMAIN_DEVICE_VSOCK:
99cbc7
-        ret = qemuDomainDetachVsockDevice(vm, dev->data.vsock, async);
99cbc7
-        break;
99cbc7
-
99cbc7
-    case VIR_DOMAIN_DEVICE_FS:
99cbc7
-    case VIR_DOMAIN_DEVICE_SOUND:
99cbc7
-    case VIR_DOMAIN_DEVICE_VIDEO:
99cbc7
-    case VIR_DOMAIN_DEVICE_GRAPHICS:
99cbc7
-    case VIR_DOMAIN_DEVICE_HUB:
99cbc7
-    case VIR_DOMAIN_DEVICE_SMARTCARD:
99cbc7
-    case VIR_DOMAIN_DEVICE_MEMBALLOON:
99cbc7
-    case VIR_DOMAIN_DEVICE_NVRAM:
99cbc7
-    case VIR_DOMAIN_DEVICE_NONE:
99cbc7
-    case VIR_DOMAIN_DEVICE_TPM:
99cbc7
-    case VIR_DOMAIN_DEVICE_PANIC:
99cbc7
-    case VIR_DOMAIN_DEVICE_IOMMU:
99cbc7
-    case VIR_DOMAIN_DEVICE_LAST:
99cbc7
-        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
99cbc7
-                       _("live detach of device '%s' is not supported"),
99cbc7
-                       virDomainDeviceTypeToString(dev->type));
99cbc7
-        break;
99cbc7
-    }
99cbc7
-
99cbc7
-    if (ret == 0)
99cbc7
-        ret = qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE);
99cbc7
-
99cbc7
-    return ret;
99cbc7
-}
99cbc7
 
99cbc7
 static int
99cbc7
 qemuDomainChangeDiskLive(virDomainObjPtr vm,
99cbc7
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
99cbc7
index d55a68e4ad..930f8d3358 100644
99cbc7
--- a/src/qemu/qemu_hotplug.c
99cbc7
+++ b/src/qemu/qemu_hotplug.c
99cbc7
@@ -5638,6 +5638,103 @@ qemuDomainDetachLease(virQEMUDriverPtr driver,
99cbc7
 }
99cbc7
 
99cbc7
 
99cbc7
+static int
99cbc7
+qemuDomainDetachDeviceControllerLive(virQEMUDriverPtr driver,
99cbc7
+                                     virDomainObjPtr vm,
99cbc7
+                                     virDomainDeviceDefPtr dev,
99cbc7
+                                     bool async)
99cbc7
+{
99cbc7
+    virDomainControllerDefPtr cont = dev->data.controller;
99cbc7
+    int ret = -1;
99cbc7
+
99cbc7
+    switch (cont->type) {
99cbc7
+    case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
99cbc7
+        ret = qemuDomainDetachControllerDevice(driver, vm, dev, async);
99cbc7
+        break;
99cbc7
+    default :
99cbc7
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
99cbc7
+                       _("'%s' controller cannot be hot unplugged."),
99cbc7
+                       virDomainControllerTypeToString(cont->type));
99cbc7
+    }
99cbc7
+    return ret;
99cbc7
+}
99cbc7
+
99cbc7
+int
99cbc7
+qemuDomainDetachDeviceLive(virDomainObjPtr vm,
99cbc7
+                           virDomainDeviceDefPtr dev,
99cbc7
+                           virQEMUDriverPtr driver,
99cbc7
+                           bool async)
99cbc7
+{
99cbc7
+    int ret = -1;
99cbc7
+
99cbc7
+    switch ((virDomainDeviceType)dev->type) {
99cbc7
+    case VIR_DOMAIN_DEVICE_DISK:
99cbc7
+        ret = qemuDomainDetachDeviceDiskLive(driver, vm, dev, async);
99cbc7
+        break;
99cbc7
+    case VIR_DOMAIN_DEVICE_CONTROLLER:
99cbc7
+        ret = qemuDomainDetachDeviceControllerLive(driver, vm, dev, async);
99cbc7
+        break;
99cbc7
+    case VIR_DOMAIN_DEVICE_LEASE:
99cbc7
+        ret = qemuDomainDetachLease(driver, vm, dev->data.lease);
99cbc7
+        break;
99cbc7
+    case VIR_DOMAIN_DEVICE_NET:
99cbc7
+        ret = qemuDomainDetachNetDevice(driver, vm, dev, async);
99cbc7
+        break;
99cbc7
+    case VIR_DOMAIN_DEVICE_HOSTDEV:
99cbc7
+        ret = qemuDomainDetachHostDevice(driver, vm, dev, async);
99cbc7
+        break;
99cbc7
+    case VIR_DOMAIN_DEVICE_CHR:
99cbc7
+        ret = qemuDomainDetachChrDevice(driver, vm, dev->data.chr, async);
99cbc7
+        break;
99cbc7
+    case VIR_DOMAIN_DEVICE_RNG:
99cbc7
+        ret = qemuDomainDetachRNGDevice(driver, vm, dev->data.rng, async);
99cbc7
+        break;
99cbc7
+    case VIR_DOMAIN_DEVICE_MEMORY:
99cbc7
+        ret = qemuDomainDetachMemoryDevice(driver, vm, dev->data.memory, async);
99cbc7
+        break;
99cbc7
+    case VIR_DOMAIN_DEVICE_SHMEM:
99cbc7
+        ret = qemuDomainDetachShmemDevice(driver, vm, dev->data.shmem, async);
99cbc7
+        break;
99cbc7
+    case VIR_DOMAIN_DEVICE_WATCHDOG:
99cbc7
+        ret = qemuDomainDetachWatchdog(driver, vm, dev->data.watchdog, async);
99cbc7
+        break;
99cbc7
+    case VIR_DOMAIN_DEVICE_INPUT:
99cbc7
+        ret = qemuDomainDetachInputDevice(vm, dev->data.input, async);
99cbc7
+        break;
99cbc7
+    case VIR_DOMAIN_DEVICE_REDIRDEV:
99cbc7
+        ret = qemuDomainDetachRedirdevDevice(driver, vm, dev->data.redirdev, async);
99cbc7
+        break;
99cbc7
+
99cbc7
+    case VIR_DOMAIN_DEVICE_VSOCK:
99cbc7
+        ret = qemuDomainDetachVsockDevice(vm, dev->data.vsock, async);
99cbc7
+        break;
99cbc7
+
99cbc7
+    case VIR_DOMAIN_DEVICE_FS:
99cbc7
+    case VIR_DOMAIN_DEVICE_SOUND:
99cbc7
+    case VIR_DOMAIN_DEVICE_VIDEO:
99cbc7
+    case VIR_DOMAIN_DEVICE_GRAPHICS:
99cbc7
+    case VIR_DOMAIN_DEVICE_HUB:
99cbc7
+    case VIR_DOMAIN_DEVICE_SMARTCARD:
99cbc7
+    case VIR_DOMAIN_DEVICE_MEMBALLOON:
99cbc7
+    case VIR_DOMAIN_DEVICE_NVRAM:
99cbc7
+    case VIR_DOMAIN_DEVICE_NONE:
99cbc7
+    case VIR_DOMAIN_DEVICE_TPM:
99cbc7
+    case VIR_DOMAIN_DEVICE_PANIC:
99cbc7
+    case VIR_DOMAIN_DEVICE_IOMMU:
99cbc7
+    case VIR_DOMAIN_DEVICE_LAST:
99cbc7
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
99cbc7
+                       _("live detach of device '%s' is not supported"),
99cbc7
+                       virDomainDeviceTypeToString(dev->type));
99cbc7
+        break;
99cbc7
+    }
99cbc7
+
99cbc7
+    if (ret == 0)
99cbc7
+        ret = qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE);
99cbc7
+
99cbc7
+    return ret;
99cbc7
+}
99cbc7
+
99cbc7
+
99cbc7
 static int
99cbc7
 qemuDomainRemoveVcpu(virQEMUDriverPtr driver,
99cbc7
                      virDomainObjPtr vm,
99cbc7
diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h
99cbc7
index 0297e42a98..30b6fcc074 100644
99cbc7
--- a/src/qemu/qemu_hotplug.h
99cbc7
+++ b/src/qemu/qemu_hotplug.h
99cbc7
@@ -160,6 +160,11 @@ int qemuDomainDetachRNGDevice(virQEMUDriverPtr driver,
99cbc7
                               virDomainRNGDefPtr rng,
99cbc7
                               bool async);
99cbc7
 
99cbc7
+int qemuDomainDetachDeviceLive(virDomainObjPtr vm,
99cbc7
+                               virDomainDeviceDefPtr dev,
99cbc7
+                               virQEMUDriverPtr driver,
99cbc7
+                               bool async);
99cbc7
+
99cbc7
 void qemuDomainRemoveVcpuAlias(virQEMUDriverPtr driver,
99cbc7
                                virDomainObjPtr vm,
99cbc7
                                const char *alias);
99cbc7
-- 
99cbc7
2.21.0
99cbc7