[PATCH v2 2/2] qemu: process: Ignore 'SHUTDOWN' event during startup

Peter Krempa pkrempa at redhat.com
Mon Jul 26 08:48:14 UTC 2021


In cases when we are adding a <transient/> disk with sharing backend
(and thus hotplugging it) we need to re-initialize ACPI tables so that
the VM boots from the correct device.

In case of 'aarch64' this has a side-effect of emitting the SHUTDOWN
event with a 'host-qmp-system-reset' reason instead of a RESET event
which can lead to killing of the qemu process on startup.

Fix this by ignoring SHUTDOWN events during startup of the VM.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_process.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index f8581fa462..ace413fbdf 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -612,14 +612,18 @@ qemuProcessHandleShutdown(qemuMonitor *mon G_GNUC_UNUSED,
     qemuDomainObjPrivate *priv;
     virObjectEvent *event = NULL;
     g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
+    virDomainState state;
+    int reason;
     int detail = 0;

     VIR_DEBUG("vm=%p", vm);

     virObjectLock(vm);

+    state = virDomainObjGetState(vm, &reason);
+
     priv = vm->privateData;
-    if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_SHUTDOWN) {
+    if (state == VIR_DOMAIN_SHUTDOWN) {
         VIR_DEBUG("Ignoring repeated SHUTDOWN event from domain %s",
                   vm->def->name);
         goto unlock;
@@ -627,6 +631,13 @@ qemuProcessHandleShutdown(qemuMonitor *mon G_GNUC_UNUSED,
         VIR_DEBUG("Ignoring SHUTDOWN event from inactive domain %s",
                   vm->def->name);
         goto unlock;
+    } else if (state == VIR_DOMAIN_PAUSED &&
+               reason == VIR_DOMAIN_PAUSED_STARTING_UP) {
+        /* aarch64 emits a SHUTDOWN instead of a reset when 'system_reset' is
+         * invoked during startup. In certain cases we force a reset during
+         * startup so that firmware picks up hotplugged devices */
+        VIR_DEBUG("ignoring shutdown event during startup");
+        goto unlock;
     }

     /* In case of fake reboot qemu shutdown state is transient so don't
-- 
2.31.1




More information about the libvir-list mailing list