]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: command: Always use '-no-shutdown'
authorPeter Krempa <pkrempa@redhat.com>
Thu, 19 Aug 2021 11:50:16 +0000 (13:50 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 25 Aug 2021 13:32:45 +0000 (15:32 +0200)
The '-no-shutdown' flag prevents qemu from terminating if a shutdown was
requested. Libvirt will handle the termination of the qemu process
anyways and using this consistently will allow greater flexibility for
the virDomainSetLifecycleAction API as well as will allow using
the 'system-reset' QMP command during startup to reinitiate devices
exported to the firmware.

This efectively partially reverts 0e034efaf9b963760516a65413fd9771034357aa

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_process.c
tests/qemuxml2argvdata/misc-no-reboot.x86_64-latest.args

index 5b743dd1adf0d7cf4d447a4a780a37666cfe4ed9..b230314f7ffdd259b0ce002dd0510e12ece93eb7 100644 (file)
@@ -6165,10 +6165,16 @@ qemuBuildPMCommandLine(virCommand *cmd,
 {
     virQEMUCaps *qemuCaps = priv->qemuCaps;
 
-    if (priv->allowReboot == VIR_TRISTATE_BOOL_NO)
-        virCommandAddArg(cmd, "-no-reboot");
-    else
+    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_SET_ACTION)) {
+        /* with new qemu we always want '-no-shutdown' on startup and we set
+         * all the other behaviour later during startup */
         virCommandAddArg(cmd, "-no-shutdown");
+    } else {
+        if (priv->allowReboot == VIR_TRISTATE_BOOL_NO)
+            virCommandAddArg(cmd, "-no-reboot");
+        else
+            virCommandAddArg(cmd, "-no-shutdown");
+    }
 
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_ACPI)) {
         if (def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON)
index 0fcc847ab8df88062b00aa7bf394d6fb7ed64dd1..f9e8b94c75c37ebd2947a91f6f9e063326749c33 100644 (file)
@@ -8765,7 +8765,9 @@ qemuProcessReconnect(void *opaque)
          * domain crashed; otherwise, if the monitor was started,
          * then we can blame ourselves, else we failed before the
          * monitor started so we don't really know. */
-        if (!priv->mon && tryMonReconn && priv->allowReboot == VIR_TRISTATE_BOOL_YES)
+        if (!priv->mon && tryMonReconn &&
+            (priv->allowReboot == VIR_TRISTATE_BOOL_YES ||
+             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_SET_ACTION)))
             state = VIR_DOMAIN_SHUTOFF_CRASHED;
         else if (priv->mon)
             state = VIR_DOMAIN_SHUTOFF_DAEMON;
index 197b6375a76fe0557ea01c49c45d347407b79cc3..f34e9c8708a5e79e9e337ae2f1c5e8908bd5d4b0 100644 (file)
@@ -23,7 +23,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
 -chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
 -mon chardev=charmonitor,id=monitor,mode=control \
 -rtc base=utc \
--no-reboot \
+-no-shutdown \
 -no-acpi \
 -boot strict=on \
 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \