Blame SOURCES/libvirt-qemu_hotplug-move-Attach-Detach-Lease-functions-with-others-of-same-type.patch

0a7476
From e40f255c06b69af3bc9df5d0e6cbd0eb253e0650 Mon Sep 17 00:00:00 2001
0a7476
Message-Id: <e40f255c06b69af3bc9df5d0e6cbd0eb253e0650@dist-git>
0a7476
From: Laine Stump <laine@laine.org>
0a7476
Date: Thu, 11 Apr 2019 15:14:39 -0400
0a7476
Subject: [PATCH] qemu_hotplug: move (Attach|Detach)Lease functions with others
0a7476
 of same type
0a7476
0a7476
The Attach and Detach Lease functions were together in the middle of
0a7476
the Detach functions. Put them at the end of their respective
0a7476
sections, since they behave differently from the other attach/detach
0a7476
functions (DetachLease doesn't use qemuDomainDeleteDevice(), and is
0a7476
always synchronous).
0a7476
0a7476
Signed-off-by: Laine Stump <laine@laine.org>
0a7476
ACKed-by: Peter Krempa <pkrempa@redhat.com>
0a7476
(cherry picked from commit 015e71c54ddf8d133905a85514239b21bc7e552e)
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-28-laine@redhat.com>
0a7476
Acked-by: Michal Privoznik <mprivozn@redhat.com>
0a7476
---
0a7476
 src/qemu/qemu_hotplug.c | 96 +++++++++++++++++++++--------------------
0a7476
 1 file changed, 50 insertions(+), 46 deletions(-)
0a7476
0a7476
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
0a7476
index 77237a895e..d55a68e4ad 100644
0a7476
--- a/src/qemu/qemu_hotplug.c
0a7476
+++ b/src/qemu/qemu_hotplug.c
0a7476
@@ -2980,6 +2980,32 @@ qemuDomainAttachVsockDevice(virQEMUDriverPtr driver,
0a7476
 }
0a7476
 
0a7476
 
0a7476
+int
0a7476
+qemuDomainAttachLease(virQEMUDriverPtr driver,
0a7476
+                      virDomainObjPtr vm,
0a7476
+                      virDomainLeaseDefPtr lease)
0a7476
+{
0a7476
+    int ret = -1;
0a7476
+    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
0a7476
+
0a7476
+    if (virDomainLeaseInsertPreAlloc(vm->def) < 0)
0a7476
+        goto cleanup;
0a7476
+
0a7476
+    if (virDomainLockLeaseAttach(driver->lockManager, cfg->uri,
0a7476
+                                 vm, lease) < 0) {
0a7476
+        virDomainLeaseInsertPreAlloced(vm->def, NULL);
0a7476
+        goto cleanup;
0a7476
+    }
0a7476
+
0a7476
+    virDomainLeaseInsertPreAlloced(vm->def, lease);
0a7476
+    ret = 0;
0a7476
+
0a7476
+ cleanup:
0a7476
+    virObjectUnref(cfg);
0a7476
+    return ret;
0a7476
+}
0a7476
+
0a7476
+
0a7476
 static int
0a7476
 qemuDomainChangeNetBridge(virDomainObjPtr vm,
0a7476
                           virDomainNetDefPtr olddev,
0a7476
@@ -5350,52 +5376,6 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
0a7476
 }
0a7476
 
0a7476
 
0a7476
-int qemuDomainAttachLease(virQEMUDriverPtr driver,
0a7476
-                          virDomainObjPtr vm,
0a7476
-                          virDomainLeaseDefPtr lease)
0a7476
-{
0a7476
-    int ret = -1;
0a7476
-    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
0a7476
-
0a7476
-    if (virDomainLeaseInsertPreAlloc(vm->def) < 0)
0a7476
-        goto cleanup;
0a7476
-
0a7476
-    if (virDomainLockLeaseAttach(driver->lockManager, cfg->uri,
0a7476
-                                 vm, lease) < 0) {
0a7476
-        virDomainLeaseInsertPreAlloced(vm->def, NULL);
0a7476
-        goto cleanup;
0a7476
-    }
0a7476
-
0a7476
-    virDomainLeaseInsertPreAlloced(vm->def, lease);
0a7476
-    ret = 0;
0a7476
-
0a7476
- cleanup:
0a7476
-    virObjectUnref(cfg);
0a7476
-    return ret;
0a7476
-}
0a7476
-
0a7476
-int qemuDomainDetachLease(virQEMUDriverPtr driver,
0a7476
-                          virDomainObjPtr vm,
0a7476
-                          virDomainLeaseDefPtr lease)
0a7476
-{
0a7476
-    virDomainLeaseDefPtr det_lease;
0a7476
-    int idx;
0a7476
-
0a7476
-    if ((idx = virDomainLeaseIndex(vm->def, lease)) < 0) {
0a7476
-        virReportError(VIR_ERR_INVALID_ARG,
0a7476
-                       _("Lease %s in lockspace %s does not exist"),
0a7476
-                       lease->key, NULLSTR(lease->lockspace));
0a7476
-        return -1;
0a7476
-    }
0a7476
-
0a7476
-    if (virDomainLockLeaseDetach(driver->lockManager, vm, lease) < 0)
0a7476
-        return -1;
0a7476
-
0a7476
-    det_lease = virDomainLeaseRemoveAt(vm->def, idx);
0a7476
-    virDomainLeaseDefFree(det_lease);
0a7476
-    return 0;
0a7476
-}
0a7476
-
0a7476
 int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
0a7476
                               virDomainObjPtr vm,
0a7476
                               virDomainChrDefPtr chr,
0a7476
@@ -5634,6 +5614,30 @@ qemuDomainDetachVsockDevice(virDomainObjPtr vm,
0a7476
 }
0a7476
 
0a7476
 
0a7476
+int
0a7476
+qemuDomainDetachLease(virQEMUDriverPtr driver,
0a7476
+                      virDomainObjPtr vm,
0a7476
+                      virDomainLeaseDefPtr lease)
0a7476
+{
0a7476
+    virDomainLeaseDefPtr det_lease;
0a7476
+    int idx;
0a7476
+
0a7476
+    if ((idx = virDomainLeaseIndex(vm->def, lease)) < 0) {
0a7476
+        virReportError(VIR_ERR_INVALID_ARG,
0a7476
+                       _("Lease %s in lockspace %s does not exist"),
0a7476
+                       lease->key, NULLSTR(lease->lockspace));
0a7476
+        return -1;
0a7476
+    }
0a7476
+
0a7476
+    if (virDomainLockLeaseDetach(driver->lockManager, vm, lease) < 0)
0a7476
+        return -1;
0a7476
+
0a7476
+    det_lease = virDomainLeaseRemoveAt(vm->def, idx);
0a7476
+    virDomainLeaseDefFree(det_lease);
0a7476
+    return 0;
0a7476
+}
0a7476
+
0a7476
+
0a7476
 static int
0a7476
 qemuDomainRemoveVcpu(virQEMUDriverPtr driver,
0a7476
                      virDomainObjPtr vm,
0a7476
-- 
0a7476
2.21.0
0a7476