[PATCH 08/22] qemu: Honor 'restart' action for 'on_poweroff'

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

 



We simply terminate qemu instead of issuing a reset as the semantics of
the setting dictate.

Fix it by handling it identically to 'fake reboot'.

We need to forbid the combination of 'onReboot' -> 'destroy' and
'onPoweroff' -> reboot though as the handling would be hairy and it
honetly makes no sense.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 docs/formatdomain.rst    | 3 ++-
 src/qemu/qemu_process.c  | 6 ++++--
 src/qemu/qemu_validate.c | 9 +++++++++
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index a894a51c00..1f3136b3f2 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -1747,7 +1747,8 @@ Each of these states allow for the same four possible actions.
    supported by the libxl hypervisor driver.)

 QEMU/KVM supports the ``on_poweroff`` and ``on_reboot`` events handling the
-``destroy`` and ``restart`` actions.
+``destroy`` and ``restart`` actions, but the combiatnion of ``on_poweroff`` set
+to ``restart`` and ``on_reboot`` set to ``destroy`` is forbidden.

 The ``on_crash`` event supports these additional actions :since:`since 0.8.4` .

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 77da9992f4..5958a48182 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -543,7 +543,8 @@ qemuProcessShutdownOrReboot(virQEMUDriver *driver,
 {
     qemuDomainObjPrivate *priv = vm->privateData;

-    if (priv->fakeReboot) {
+    if (priv->fakeReboot ||
+        vm->def->onPoweroff == VIR_DOMAIN_LIFECYCLE_ACTION_RESTART) {
         g_autofree char *name = g_strdup_printf("reboot-%s", vm->def->name);
         virThread th;

@@ -619,7 +620,8 @@ qemuProcessHandleShutdown(qemuMonitor *mon G_GNUC_UNUSED,

     /* In case of fake reboot qemu shutdown state is transient so don't
      * change domain state nor send events. */
-    if (!priv->fakeReboot) {
+    if (!priv->fakeReboot ||
+        vm->def->onPoweroff != VIR_DOMAIN_LIFECYCLE_ACTION_RESTART) {
         VIR_DEBUG("Transitioned guest %s to shutdown state",
                   vm->def->name);
         virDomainObjSetState(vm,
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index d27c3b6c6c..8906aa52d9 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1089,6 +1089,15 @@ qemuValidateLifecycleAction(virDomainLifecycleAction onPoweroff,
         return -1;
     }

+    /* the qemu driver can't meaningfully handle
+     * onPoweroff -> reboot + onReboot -> destroy */
+    if (onPoweroff == VIR_DOMAIN_LIFECYCLE_ACTION_RESTART &&
+        onReboot == VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("qemu driver doesn't support 'onReboot' set to 'destroy and 'onPoweroff' set to 'reboot'"));
+        return -1;
+    }
+
     return 0;
 }

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