[PATCH] qemu: process: Ignore 'RESET' event during startup

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. This has a side-effect of emitting the RESET event and handling it which in case when the 'on_reset' policy is set to 'destroy' can even kill the VM. Fix this by ignoring RESET events during startup of the VM. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_process.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 521fda57da..d6ed4a3943 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -429,12 +429,20 @@ qemuProcessHandleReset(qemuMonitor *mon G_GNUC_UNUSED, void *opaque) { virQEMUDriver *driver = opaque; - virObjectEvent *event; + virObjectEvent *event = NULL; qemuDomainObjPrivate *priv; g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); virObjectLock(vm); + /* ignore reset events on VM startup. Libvirt in certain instances does a + * reset during startup so that the ACPI tables are re-generated */ + if (vm->state.state == VIR_DOMAIN_PAUSED && + vm->state.reason == VIR_DOMAIN_PAUSED_STARTING_UP) { + VIR_DEBUG("ignoring reset event during startup"); + goto cleanup; + } + event = virDomainEventRebootNewFromObj(vm); priv = vm->privateData; if (priv->agent) -- 2.31.1

On Fri, Jul 23, 2021 at 16:46:14 +0200, Peter Krempa wrote:
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.
This has a side-effect of emitting the RESET event and handling it which in case when the 'on_reset' policy is set to 'destroy' can even kill the VM.
Fix this by ignoring RESET events during startup of the VM.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_process.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
I'll be posting another version of this as QEMU on aarch64 uses a SHUTDOWN event instead of RESET.
participants (1)
-
Peter Krempa