render / rpms / libvirt

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