[PATCH 18/22] qemuProcessLaunch: Setup handling of 'on_reboot' via QMP when starting the process

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

 



Rather than using '-no-reboot' use the QMP command to update the
lifecycle action of 'on_reboot'.

This will be identical to how we set the behaviour during lifetime and
also avoids problems with use of the 'system-reset' QMP command during
bringup of the VM (used to update the firmware table of disks when disks
were hotplugged as part of startup).

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_process.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index a839d587c2..c41c6ab793 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7024,6 +7024,37 @@ qemuProcessSetupDisksTransient(virDomainObj *vm,
 }


+static int
+qemuProcessSetupLifecycleActions(virDomainObj *vm,
+                                 qemuDomainAsyncJob asyncJob)
+{
+    qemuDomainObjPrivate *priv = vm->privateData;
+    int rc;
+
+    if (!(virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_SET_ACTION)))
+        return 0;
+
+    /* for now we handle only onReboot->destroy here as an alternative to
+     * '-no-reboot' on the commandline */
+    if (vm->def->onReboot != VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY)
+        return 0;
+
+    if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0)
+        return -1;
+
+    rc = qemuMonitorSetAction(priv->mon,
+                              QEMU_MONITOR_ACTION_SHUTDOWN_KEEP,
+                              QEMU_MONITOR_ACTION_REBOOT_SHUTDOWN,
+                              QEMU_MONITOR_ACTION_WATCHDOG_KEEP,
+                              QEMU_MONITOR_ACTION_PANIC_KEEP);
+
+    if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0)
+        return -1;
+
+    return 0;
+}
+
+
 /**
  * qemuProcessLaunch:
  *
@@ -7382,6 +7413,10 @@ qemuProcessLaunch(virConnectPtr conn,
             goto cleanup;
     }

+    VIR_DEBUG("Setting handling of lifecycle actions");
+    if (qemuProcessSetupLifecycleActions(vm, asyncJob) < 0)
+        goto cleanup;
+
     ret = 0;

  cleanup:
-- 
2.31.1




[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