[PATCH 11/13] conf: domain: Add helper to check whether a domain def requires use of PR

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Extract the lookup code so that it can be reused later.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_conf.c   | 21 +++++++++++++++++++++
 src/conf/domain_conf.h   |  3 +++
 src/libvirt_private.syms |  1 +
 src/qemu/qemu_process.c  | 23 ++---------------------
 4 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 86229db654..6f16e4ade4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -29528,3 +29528,24 @@ virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard,

     return detect_zeroes;
 }
+
+
+/**
+ * virDomainDefHasManagedPR:
+ * @def: domain definition
+ *
+ * Returns true if any of the domain disks requires the use of the managed
+ * persistent reservations infrastructure.
+ */
+bool
+virDomainDefHasManagedPR(const virDomainDef *def)
+{
+    size_t i;
+
+    for (i = 0; i < def->ndisks; i++) {
+        if (virStoragePRDefIsManaged(def->disks[i]->src->pr))
+            return true;
+    }
+
+    return false;
+}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 07d04fb2f9..f1add06155 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3543,4 +3543,7 @@ int
 virDomainDiskGetDetectZeroesMode(virDomainDiskDiscard discard,
                                  virDomainDiskDetectZeroes detect_zeroes);

+bool
+virDomainDefHasManagedPR(const virDomainDef *def);
+
 #endif /* __DOMAIN_CONF_H */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index dd10be9753..a0b78f72ba 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -275,6 +275,7 @@ virDomainDefGetVcpus;
 virDomainDefGetVcpusMax;
 virDomainDefGetVcpusTopology;
 virDomainDefHasDeviceAddress;
+virDomainDefHasManagedPR;
 virDomainDefHasMemballoon;
 virDomainDefHasMemoryHotplug;
 virDomainDefHasUSB;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index af29bcc59e..5b73a61962 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2748,26 +2748,6 @@ qemuProcessStartManagedPRDaemon(virDomainObjPtr vm)
 }


-static int
-qemuProcessMaybeStartManagedPRDaemon(virDomainObjPtr vm)
-{
-    bool hasManaged = false;
-    size_t i;
-
-    for (i = 0; i < vm->def->ndisks; i++) {
-        if (virStoragePRDefIsManaged(vm->def->disks[i]->src->pr)) {
-            hasManaged = true;
-            break;
-        }
-    }
-
-    if (!hasManaged)
-        return 0;
-
-    return qemuProcessStartManagedPRDaemon(vm);
-}
-
-
 static int
 qemuProcessInitPasswords(virQEMUDriverPtr driver,
                          virDomainObjPtr vm,
@@ -6285,7 +6265,8 @@ qemuProcessLaunch(virConnectPtr conn,
         goto cleanup;

     VIR_DEBUG("Setting up managed PR daemon");
-    if (qemuProcessMaybeStartManagedPRDaemon(vm) < 0)
+    if (virDomainDefHasManagedPR(vm->def) &&
+        qemuProcessStartManagedPRDaemon(vm) < 0)
         goto cleanup;

     VIR_DEBUG("Setting domain security labels");
-- 
2.16.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux