On Wed, Jul 04, 2018 at 12:46:53 +0200, Michal Privoznik wrote:
This event is emitted on the monitor if one of pr-managers lost
connection to its pr-helper process. What libvirt needs to do is
restart the pr-helper process iff it corresponds to managed
pr-manager.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_monitor.c | 15 +++++++++++++
src/qemu/qemu_monitor.h | 11 +++++++++
src/qemu/qemu_monitor_json.c | 23 +++++++++++++++++++
src/qemu/qemu_process.c | 53 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 102 insertions(+)
[...]
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index f200729cb1..94b7de76d7 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1615,6 +1615,58 @@ qemuProcessHandleDumpCompleted(qemuMonitorPtr mon
ATTRIBUTE_UNUSED,
}
+static int
+qemuProcessHandlePRManagerStatusChanged(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
+ virDomainObjPtr vm,
+ const char *prManager,
+ bool connected,
+ void *opaque ATTRIBUTE_UNUSED)
+{
+ qemuDomainObjPrivatePtr priv;
+ size_t i;
+ int ret = -1;
+
+ virObjectLock(vm);
+
+ VIR_DEBUG("pr-manager %s status changed for domain %p %s connected=%d",
+ prManager, vm, vm->def->name, connected);
+
+ if (connected) {
+ /* Connect events are boring. */
+ ret = 0;
+ goto cleanup;
+ }
+ /* Disconnect events are more interesting. */
+
+ for (i = 0; i < vm->def->ndisks; i++) {
+ const char *mgralias;
+
+ mgralias =
virStorageSourceChainGetManagedPRAlias(vm->def->disks[i]->src);
+
+ if (STREQ_NULLABLE(prManager, mgralias))
+ break;
I'm not a fan of this. We always know which is the managed alias and we
also know if it is supposed to be running.
The hotplug code already does not inspect disks to do this since there
is only one instance.
+ }
+
+ if (i == vm->def->ndisks) {
+ VIR_DEBUG("pr-manager %s not managed, ignoring event",
+ prManager);
+ ret = 0;
+ goto cleanup;
+ }
+
+ priv = vm->privateData;
+ priv->prDaemonRunning = false;
+
+ if (qemuProcessStartManagedPRDaemon(vm) < 0)
This has a timeout built in. Thus executing this from the event loop
will make the whole libvirtd get stuck until it starts. This should not
be in the event loop.
Also does every disconnect equal to the daemon crashing/stopping?
+ goto cleanup;
+
+ ret = 0;