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

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