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(a)redhat.com>
---
src/qemu/qemu_command.c | 12 +++++++++---
src/qemu/qemu_process.c | 4 +++-
.../misc-no-reboot.x86_64-latest.args | 2 +-
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5b743dd1ad..b230314f7f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -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)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c41c6ab793..bbcef47885 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -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;
diff --git a/tests/qemuxml2argvdata/misc-no-reboot.x86_64-latest.args
b/tests/qemuxml2argvdata/misc-no-reboot.x86_64-latest.args
index 197b6375a7..f34e9c8708 100644
--- a/tests/qemuxml2argvdata/misc-no-reboot.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/misc-no-reboot.x86_64-latest.args
@@ -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 \
--
2.31.1