[PATCH 23/25] qemu: Detect managed persistent reservations in block job orphan chains

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

 



The PR manager is a property of the format layer in qemu so we need to
be able to track it also in the chains of orphaned block jobs.

Add a helper for qemu to look also into the blockjob state.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c  | 41 +++++++++++++++++++++++++++++++++++++++++
 src/qemu/qemu_domain.h  |  2 ++
 src/qemu/qemu_driver.c  |  2 +-
 src/qemu/qemu_hotplug.c |  2 +-
 src/qemu/qemu_process.c |  2 +-
 5 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 48b99e5511..3a5bd2f921 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -14740,3 +14740,44 @@ qemuDomainPausedReasonToSuspendedEvent(virDomainPausedReason reason)

     return VIR_DOMAIN_EVENT_SUSPENDED_PAUSED;
 }
+
+
+static int
+qemuDomainDefHasManagedPRBlockjobIterator(void *payload,
+                                          const void *name ATTRIBUTE_UNUSED,
+                                          void *opaque)
+{
+    qemuBlockJobDataPtr job = payload;
+    bool *hasPR = opaque;
+
+    if (job->disk)
+        return 0;
+
+    if ((job->chain && virStorageSourceChainHasManagedPR(job->chain)) ||
+        (job->mirrorChain && virStorageSourceChainHasManagedPR(job->mirrorChain)))
+        *hasPR = true;
+
+    return 0;
+}
+
+
+/**
+ * qemuDomainDefHasManagedPR:
+ * @vm: domain object
+ *
+ * @vm must be an active VM. Returns true if @vm has any storage source with
+ * managed persistent reservations.
+ */
+bool
+qemuDomainDefHasManagedPR(virDomainObjPtr vm)
+{
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    bool jobPR = false;
+
+    if (virDomainDefHasManagedPR(vm->def))
+        return true;
+
+    virHashForEach(priv->blockjobs, qemuDomainDefHasManagedPRBlockjobIterator, &jobPR);
+
+    return jobPR;
+}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 3ccea3177e..11dad90c81 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -1141,6 +1141,8 @@ qemuDomainDiskCachemodeFlags(int cachemode,

 char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv);

+bool qemuDomainDefHasManagedPR(virDomainObjPtr vm);
+
 unsigned int qemuDomainStorageIdNew(qemuDomainObjPrivatePtr priv);
 void qemuDomainStorageIdReset(qemuDomainObjPrivatePtr priv);

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 604beca155..238d59466c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4792,7 +4792,7 @@ processPRDisconnectEvent(virDomainObjPtr vm)
         return;

     if (!priv->prDaemonRunning &&
-        virDomainDefHasManagedPR(vm->def))
+        qemuDomainDefHasManagedPR(vm))
         qemuProcessStartManagedPRDaemon(vm);
 }

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 7e9c1a1649..c50e41144e 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -397,7 +397,7 @@ qemuHotplugRemoveManagedPR(virQEMUDriverPtr driver,
     virErrorPtr orig_err;
     int ret = -1;

-    if (virDomainDefHasManagedPR(vm->def))
+    if (qemuDomainDefHasManagedPR(vm))
         return 0;

     virErrorPreserveLast(&orig_err);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 3afdaafb23..aaff1beeaa 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2309,7 +2309,7 @@ qemuRefreshPRManagerState(virQEMUDriverPtr driver,
     int ret = -1;

     if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_PR_MANAGER_HELPER) ||
-        !virDomainDefHasManagedPR(vm->def))
+        !qemuDomainDefHasManagedPR(vm))
         return 0;

     qemuDomainObjEnterMonitor(driver, vm);
-- 
2.21.0

--
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