982648
From 01aa947e223d82d4663270f1ac7ff2af3b31ccca Mon Sep 17 00:00:00 2001
982648
Message-Id: <01aa947e223d82d4663270f1ac7ff2af3b31ccca@dist-git>
982648
From: Michal Privoznik <mprivozn@redhat.com>
982648
Date: Wed, 11 Jul 2018 17:27:28 +0200
982648
Subject: [PATCH] qemu: Fetch pr-helper process info on reconnect
982648
MIME-Version: 1.0
982648
Content-Type: text/plain; charset=UTF-8
982648
Content-Transfer-Encoding: 8bit
982648
982648
https://bugzilla.redhat.com/show_bug.cgi?id=1470007
982648
982648
If qemu-pr-helper process died while libvirtd was not running no
982648
event is emitted. Therefore, when reconnecting to the monitor we
982648
must check the qemu-pr-helper process status and act accordingly.
982648
982648
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
982648
(cherry picked from commit ab435a4be4673a9a38e0315864b9cf4f9bee03e7)
982648
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
982648
Reviewed-by: Ján Tomko <jtomko@redhat.com>
982648
---
982648
 src/qemu/qemu_process.c | 60 +++++++++++++++++++++++++++++++++++++++++
982648
 1 file changed, 60 insertions(+)
982648
982648
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
982648
index fbc8529f3b..c903a8e5c8 100644
982648
--- a/src/qemu/qemu_process.c
982648
+++ b/src/qemu/qemu_process.c
982648
@@ -2071,6 +2071,63 @@ qemuRefreshVirtioChannelState(virQEMUDriverPtr driver,
982648
     return ret;
982648
 }
982648
 
982648
+
982648
+static int
982648
+qemuProcessRefreshPRManagerState(virDomainObjPtr vm,
982648
+                                 virHashTablePtr info)
982648
+{
982648
+    qemuDomainObjPrivatePtr priv = vm->privateData;
982648
+    qemuMonitorPRManagerInfoPtr prManagerInfo;
982648
+    const char *managedAlias = qemuDomainGetManagedPRAlias();
982648
+    int ret = -1;
982648
+
982648
+    if (!(prManagerInfo = virHashLookup(info, managedAlias))) {
982648
+        virReportError(VIR_ERR_OPERATION_FAILED,
982648
+                       _("missing info on pr-manager %s"),
982648
+                       managedAlias);
982648
+        goto cleanup;
982648
+    }
982648
+
982648
+    priv->prDaemonRunning = prManagerInfo->connected;
982648
+
982648
+    if (!priv->prDaemonRunning &&
982648
+        qemuProcessStartManagedPRDaemon(vm) < 0)
982648
+        goto cleanup;
982648
+
982648
+    ret = 0;
982648
+ cleanup:
982648
+    return ret;
982648
+}
982648
+
982648
+
982648
+static int
982648
+qemuRefreshPRManagerState(virQEMUDriverPtr driver,
982648
+                          virDomainObjPtr vm)
982648
+{
982648
+    qemuDomainObjPrivatePtr priv = vm->privateData;
982648
+    virHashTablePtr info = NULL;
982648
+    int ret = -1;
982648
+
982648
+    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_PR_MANAGER_HELPER) ||
982648
+        !virDomainDefHasManagedPR(vm->def))
982648
+        return 0;
982648
+
982648
+    qemuDomainObjEnterMonitor(driver, vm);
982648
+    ret = qemuMonitorGetPRManagerInfo(priv->mon, &info;;
982648
+    if (qemuDomainObjExitMonitor(driver, vm) < 0)
982648
+        ret = -1;
982648
+
982648
+    if (ret < 0)
982648
+        goto cleanup;
982648
+
982648
+    ret = qemuProcessRefreshPRManagerState(vm, info);
982648
+
982648
+ cleanup:
982648
+    virHashFree(info);
982648
+    return ret;
982648
+}
982648
+
982648
+
982648
 static void
982648
 qemuRefreshRTC(virQEMUDriverPtr driver,
982648
                virDomainObjPtr vm)
982648
@@ -7736,6 +7793,9 @@ qemuProcessReconnect(void *opaque)
982648
     if (qemuProcessUpdateDevices(driver, obj) < 0)
982648
         goto error;
982648
 
982648
+    if (qemuRefreshPRManagerState(driver, obj) < 0)
982648
+        goto error;
982648
+
982648
     qemuProcessReconnectCheckMemAliasOrderMismatch(obj);
982648
 
982648
     if (qemuConnectAgent(driver, obj) < 0)
982648
-- 
982648
2.18.0
982648