render / rpms / libvirt

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