[libvirt] [PATCH 11/21] qemu_hotplug: move (almost) all qemuDomainDetach*() functions together

Laine Stump laine at laine.org
Thu Mar 21 22:28:51 UTC 2019


There were two outliers at the end of the file beyond the Vcpu
functions.

Signed-off-by: Laine Stump <laine at laine.org>
---
 src/qemu/qemu_hotplug.c | 174 ++++++++++++++++++++--------------------
 1 file changed, 87 insertions(+), 87 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index ca89cf5d97..094d135aac 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -6102,6 +6102,93 @@ qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver,
 }
 
 
+int
+qemuDomainDetachInputDevice(virDomainObjPtr vm,
+                            virDomainInputDefPtr def,
+                            bool async)
+{
+    virDomainInputDefPtr input;
+    int ret = -1;
+    int idx;
+
+    if ((idx = virDomainInputDefFind(vm->def, def)) < 0) {
+        virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+                       _("matching input device not found"));
+        return -1;
+    }
+    input = vm->def->inputs[idx];
+
+    switch ((virDomainInputBus) input->bus) {
+    case VIR_DOMAIN_INPUT_BUS_PS2:
+    case VIR_DOMAIN_INPUT_BUS_XEN:
+    case VIR_DOMAIN_INPUT_BUS_PARALLELS:
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+                       _("input device on bus '%s' cannot be detached"),
+                       virDomainInputBusTypeToString(input->bus));
+        return -1;
+
+    case VIR_DOMAIN_INPUT_BUS_LAST:
+    case VIR_DOMAIN_INPUT_BUS_USB:
+    case VIR_DOMAIN_INPUT_BUS_VIRTIO:
+        break;
+    }
+
+    if (!async)
+        qemuDomainMarkDeviceForRemoval(vm, &input->info);
+
+    if (qemuDomainDeleteDevice(vm, input->info.alias) < 0)
+        goto cleanup;
+
+    if (async) {
+        ret = 0;
+    } else {
+        if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
+            ret = qemuDomainRemoveInputDevice(vm, input);
+    }
+
+ cleanup:
+    if (!async)
+        qemuDomainResetDeviceRemoval(vm);
+    return ret;
+}
+
+
+int
+qemuDomainDetachVsockDevice(virDomainObjPtr vm,
+                            virDomainVsockDefPtr dev,
+                            bool async)
+{
+    virDomainVsockDefPtr vsock = vm->def->vsock;
+    int ret = -1;
+
+
+    if (!vsock ||
+        !virDomainVsockDefEquals(dev, vsock)) {
+        virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+                       _("matching vsock device not found"));
+        return -1;
+    }
+
+    if (!async)
+        qemuDomainMarkDeviceForRemoval(vm, &vsock->info);
+
+    if (qemuDomainDeleteDevice(vm, vsock->info.alias) < 0)
+        goto cleanup;
+
+    if (async) {
+        ret = 0;
+    } else {
+        if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
+            ret = qemuDomainRemoveVsockDevice(vm, vsock);
+    }
+
+ cleanup:
+    if (!async)
+        qemuDomainResetDeviceRemoval(vm);
+    return ret;
+}
+
+
 static int
 qemuDomainRemoveVcpu(virQEMUDriverPtr driver,
                      virDomainObjPtr vm,
@@ -6755,90 +6842,3 @@ qemuDomainSetVcpuInternal(virQEMUDriverPtr driver,
     virObjectUnref(cfg);
     return ret;
 }
-
-
-int
-qemuDomainDetachInputDevice(virDomainObjPtr vm,
-                            virDomainInputDefPtr def,
-                            bool async)
-{
-    virDomainInputDefPtr input;
-    int ret = -1;
-    int idx;
-
-    if ((idx = virDomainInputDefFind(vm->def, def)) < 0) {
-        virReportError(VIR_ERR_OPERATION_FAILED, "%s",
-                       _("matching input device not found"));
-        return -1;
-    }
-    input = vm->def->inputs[idx];
-
-    switch ((virDomainInputBus) input->bus) {
-    case VIR_DOMAIN_INPUT_BUS_PS2:
-    case VIR_DOMAIN_INPUT_BUS_XEN:
-    case VIR_DOMAIN_INPUT_BUS_PARALLELS:
-        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
-                       _("input device on bus '%s' cannot be detached"),
-                       virDomainInputBusTypeToString(input->bus));
-        return -1;
-
-    case VIR_DOMAIN_INPUT_BUS_LAST:
-    case VIR_DOMAIN_INPUT_BUS_USB:
-    case VIR_DOMAIN_INPUT_BUS_VIRTIO:
-        break;
-    }
-
-    if (!async)
-        qemuDomainMarkDeviceForRemoval(vm, &input->info);
-
-    if (qemuDomainDeleteDevice(vm, input->info.alias) < 0)
-        goto cleanup;
-
-    if (async) {
-        ret = 0;
-    } else {
-        if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
-            ret = qemuDomainRemoveInputDevice(vm, input);
-    }
-
- cleanup:
-    if (!async)
-        qemuDomainResetDeviceRemoval(vm);
-    return ret;
-}
-
-
-int
-qemuDomainDetachVsockDevice(virDomainObjPtr vm,
-                            virDomainVsockDefPtr dev,
-                            bool async)
-{
-    virDomainVsockDefPtr vsock = vm->def->vsock;
-    int ret = -1;
-
-
-    if (!vsock ||
-        !virDomainVsockDefEquals(dev, vsock)) {
-        virReportError(VIR_ERR_OPERATION_FAILED, "%s",
-                       _("matching vsock device not found"));
-        return -1;
-    }
-
-    if (!async)
-        qemuDomainMarkDeviceForRemoval(vm, &vsock->info);
-
-    if (qemuDomainDeleteDevice(vm, vsock->info.alias) < 0)
-        goto cleanup;
-
-    if (async) {
-        ret = 0;
-    } else {
-        if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
-            ret = qemuDomainRemoveVsockDevice(vm, vsock);
-    }
-
- cleanup:
-    if (!async)
-        qemuDomainResetDeviceRemoval(vm);
-    return ret;
-}
-- 
2.20.1




More information about the libvir-list mailing list