render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
0a7476
From efbfb47fa2b48ea4879a8897a2613963658adb89 Mon Sep 17 00:00:00 2001
0a7476
Message-Id: <efbfb47fa2b48ea4879a8897a2613963658adb89@dist-git>
0a7476
From: Laine Stump <laine@laine.org>
0a7476
Date: Thu, 11 Apr 2019 15:14:38 -0400
0a7476
Subject: [PATCH] qemu_hotplug: move (almost) all qemuDomainDetach*() functions
0a7476
 together
0a7476
0a7476
There were two outliers at the end of the file beyond the Vcpu
0a7476
functions.
0a7476
0a7476
Signed-off-by: Laine Stump <laine@laine.org>
0a7476
ACKed-by: Peter Krempa <pkrempa@redhat.com>
0a7476
(cherry picked from commit 5a8ffaec768ce25ef74eb398968e0b84b878a249)
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-27-laine@redhat.com>
0a7476
Acked-by: Michal Privoznik <mprivozn@redhat.com>
0a7476
---
0a7476
 src/qemu/qemu_hotplug.c | 174 ++++++++++++++++++++--------------------
0a7476
 1 file changed, 87 insertions(+), 87 deletions(-)
0a7476
0a7476
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
0a7476
index d80b9b005b..77237a895e 100644
0a7476
--- a/src/qemu/qemu_hotplug.c
0a7476
+++ b/src/qemu/qemu_hotplug.c
0a7476
@@ -5547,6 +5547,93 @@ qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver,
0a7476
 }
0a7476
 
0a7476
 
0a7476
+int
0a7476
+qemuDomainDetachInputDevice(virDomainObjPtr vm,
0a7476
+                            virDomainInputDefPtr def,
0a7476
+                            bool async)
0a7476
+{
0a7476
+    virDomainInputDefPtr input;
0a7476
+    int ret = -1;
0a7476
+    int idx;
0a7476
+
0a7476
+    if ((idx = virDomainInputDefFind(vm->def, def)) < 0) {
0a7476
+        virReportError(VIR_ERR_OPERATION_FAILED, "%s",
0a7476
+                       _("matching input device not found"));
0a7476
+        return -1;
0a7476
+    }
0a7476
+    input = vm->def->inputs[idx];
0a7476
+
0a7476
+    switch ((virDomainInputBus) input->bus) {
0a7476
+    case VIR_DOMAIN_INPUT_BUS_PS2:
0a7476
+    case VIR_DOMAIN_INPUT_BUS_XEN:
0a7476
+    case VIR_DOMAIN_INPUT_BUS_PARALLELS:
0a7476
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
0a7476
+                       _("input device on bus '%s' cannot be detached"),
0a7476
+                       virDomainInputBusTypeToString(input->bus));
0a7476
+        return -1;
0a7476
+
0a7476
+    case VIR_DOMAIN_INPUT_BUS_LAST:
0a7476
+    case VIR_DOMAIN_INPUT_BUS_USB:
0a7476
+    case VIR_DOMAIN_INPUT_BUS_VIRTIO:
0a7476
+        break;
0a7476
+    }
0a7476
+
0a7476
+    if (!async)
0a7476
+        qemuDomainMarkDeviceForRemoval(vm, &input->info);
0a7476
+
0a7476
+    if (qemuDomainDeleteDevice(vm, input->info.alias) < 0)
0a7476
+        goto cleanup;
0a7476
+
0a7476
+    if (async) {
0a7476
+        ret = 0;
0a7476
+    } else {
0a7476
+        if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
0a7476
+            ret = qemuDomainRemoveInputDevice(vm, input);
0a7476
+    }
0a7476
+
0a7476
+ cleanup:
0a7476
+    if (!async)
0a7476
+        qemuDomainResetDeviceRemoval(vm);
0a7476
+    return ret;
0a7476
+}
0a7476
+
0a7476
+
0a7476
+int
0a7476
+qemuDomainDetachVsockDevice(virDomainObjPtr vm,
0a7476
+                            virDomainVsockDefPtr dev,
0a7476
+                            bool async)
0a7476
+{
0a7476
+    virDomainVsockDefPtr vsock = vm->def->vsock;
0a7476
+    int ret = -1;
0a7476
+
0a7476
+
0a7476
+    if (!vsock ||
0a7476
+        !virDomainVsockDefEquals(dev, vsock)) {
0a7476
+        virReportError(VIR_ERR_OPERATION_FAILED, "%s",
0a7476
+                       _("matching vsock device not found"));
0a7476
+        return -1;
0a7476
+    }
0a7476
+
0a7476
+    if (!async)
0a7476
+        qemuDomainMarkDeviceForRemoval(vm, &vsock->info);
0a7476
+
0a7476
+    if (qemuDomainDeleteDevice(vm, vsock->info.alias) < 0)
0a7476
+        goto cleanup;
0a7476
+
0a7476
+    if (async) {
0a7476
+        ret = 0;
0a7476
+    } else {
0a7476
+        if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
0a7476
+            ret = qemuDomainRemoveVsockDevice(vm, vsock);
0a7476
+    }
0a7476
+
0a7476
+ cleanup:
0a7476
+    if (!async)
0a7476
+        qemuDomainResetDeviceRemoval(vm);
0a7476
+    return ret;
0a7476
+}
0a7476
+
0a7476
+
0a7476
 static int
0a7476
 qemuDomainRemoveVcpu(virQEMUDriverPtr driver,
0a7476
                      virDomainObjPtr vm,
0a7476
@@ -6200,90 +6287,3 @@ qemuDomainSetVcpuInternal(virQEMUDriverPtr driver,
0a7476
     virObjectUnref(cfg);
0a7476
     return ret;
0a7476
 }
0a7476
-
0a7476
-
0a7476
-int
0a7476
-qemuDomainDetachInputDevice(virDomainObjPtr vm,
0a7476
-                            virDomainInputDefPtr def,
0a7476
-                            bool async)
0a7476
-{
0a7476
-    virDomainInputDefPtr input;
0a7476
-    int ret = -1;
0a7476
-    int idx;
0a7476
-
0a7476
-    if ((idx = virDomainInputDefFind(vm->def, def)) < 0) {
0a7476
-        virReportError(VIR_ERR_OPERATION_FAILED, "%s",
0a7476
-                       _("matching input device not found"));
0a7476
-        return -1;
0a7476
-    }
0a7476
-    input = vm->def->inputs[idx];
0a7476
-
0a7476
-    switch ((virDomainInputBus) input->bus) {
0a7476
-    case VIR_DOMAIN_INPUT_BUS_PS2:
0a7476
-    case VIR_DOMAIN_INPUT_BUS_XEN:
0a7476
-    case VIR_DOMAIN_INPUT_BUS_PARALLELS:
0a7476
-        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
0a7476
-                       _("input device on bus '%s' cannot be detached"),
0a7476
-                       virDomainInputBusTypeToString(input->bus));
0a7476
-        return -1;
0a7476
-
0a7476
-    case VIR_DOMAIN_INPUT_BUS_LAST:
0a7476
-    case VIR_DOMAIN_INPUT_BUS_USB:
0a7476
-    case VIR_DOMAIN_INPUT_BUS_VIRTIO:
0a7476
-        break;
0a7476
-    }
0a7476
-
0a7476
-    if (!async)
0a7476
-        qemuDomainMarkDeviceForRemoval(vm, &input->info);
0a7476
-
0a7476
-    if (qemuDomainDeleteDevice(vm, input->info.alias) < 0)
0a7476
-        goto cleanup;
0a7476
-
0a7476
-    if (async) {
0a7476
-        ret = 0;
0a7476
-    } else {
0a7476
-        if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
0a7476
-            ret = qemuDomainRemoveInputDevice(vm, input);
0a7476
-    }
0a7476
-
0a7476
- cleanup:
0a7476
-    if (!async)
0a7476
-        qemuDomainResetDeviceRemoval(vm);
0a7476
-    return ret;
0a7476
-}
0a7476
-
0a7476
-
0a7476
-int
0a7476
-qemuDomainDetachVsockDevice(virDomainObjPtr vm,
0a7476
-                            virDomainVsockDefPtr dev,
0a7476
-                            bool async)
0a7476
-{
0a7476
-    virDomainVsockDefPtr vsock = vm->def->vsock;
0a7476
-    int ret = -1;
0a7476
-
0a7476
-
0a7476
-    if (!vsock ||
0a7476
-        !virDomainVsockDefEquals(dev, vsock)) {
0a7476
-        virReportError(VIR_ERR_OPERATION_FAILED, "%s",
0a7476
-                       _("matching vsock device not found"));
0a7476
-        return -1;
0a7476
-    }
0a7476
-
0a7476
-    if (!async)
0a7476
-        qemuDomainMarkDeviceForRemoval(vm, &vsock->info);
0a7476
-
0a7476
-    if (qemuDomainDeleteDevice(vm, vsock->info.alias) < 0)
0a7476
-        goto cleanup;
0a7476
-
0a7476
-    if (async) {
0a7476
-        ret = 0;
0a7476
-    } else {
0a7476
-        if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
0a7476
-            ret = qemuDomainRemoveVsockDevice(vm, vsock);
0a7476
-    }
0a7476
-
0a7476
- cleanup:
0a7476
-    if (!async)
0a7476
-        qemuDomainResetDeviceRemoval(vm);
0a7476
-    return ret;
0a7476
-}
0a7476
-- 
0a7476
2.21.0
0a7476