From 64e5603f8ea139cd8b7c61b643a0a02bba5885c3 Mon Sep 17 00:00:00 2001 Message-ID: <64e5603f8ea139cd8b7c61b643a0a02bba5885c3.1787144643.git.jdenemar@redhat.com> From: Peter Krempa Date: Wed, 22 Jul 2026 17:13:15 +0200 Subject: [PATCH] Add support for keeping VM running when panic notifier is used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some guest OSes (e.g. windows) can do an internal crash dump and reboot after a crash. They unfortunately notify the OS before doing the crash dump though so we need a new possibility for the action to keep the VM as is. This patch introduces 'preserve-running' mode for on_crash and wires it up into the qemu driver. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko (cherry picked from commit cdea89dd87a10cd94deb3b067bae483d98c558ed) https://redhat.atlassian.net/browse/RHEL-242546 --- docs/formatdomain.rst | 3 ++ include/libvirt/libvirt-domain.h | 1 + src/conf/domain_conf.c | 2 ++ src/conf/schemas/domaincommon.rng | 2 ++ src/libxl/libxl_conf.c | 1 + src/libxl/libxl_domain.c | 3 ++ src/qemu/qemu_driver.c | 34 ++++++++++++++++++- src/qemu/qemu_process.c | 18 ++++++++++ .../async-teardown.x86_64-latest.xml | 2 +- tests/qemuxmlconfdata/async-teardown.xml | 2 +- tests/qemuxmlconftest.c | 1 + tools/virsh-domain.c | 3 +- 12 files changed, 68 insertions(+), 4 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 8e7577f3b7..b48254f35b 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -1998,6 +1998,9 @@ The ``on_crash`` event supports these additional actions :since:`since 0.8.4`. ``coredump-restart`` The crashed domain's core will be dumped, and then the domain will be restarted with the same configuration +``preserve-running`` + The crashed domain will continue to run. This is useful if the guest OS can + do an internal crash dump and reboot itself. :since:`Since 12.6.0` :since:`Since 3.9.0`, the lifecycle events can be configured via the `virDomainSetLifecycleAction `__ diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 4d7c0099ef..f469ed428d 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -7955,6 +7955,7 @@ typedef enum { VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE = 3, /* (Since: 3.9.0) */ VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY = 4, /* (Since: 3.9.0) */ VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART = 5, /* (Since: 3.9.0) */ + VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE_RUNNING = 6, /* (Since: 12.6.0) */ # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_LIFECYCLE_ACTION_LAST /* (Since: 3.9.0) */ diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7097ff7065..048aaa10a6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -302,6 +302,7 @@ VIR_ENUM_IMPL(virDomainLifecycleAction, "preserve", "coredump-destroy", "coredump-restart", + "preserve-running", ); VIR_ENUM_IMPL(virDomainLockFailure, @@ -5483,6 +5484,7 @@ virDomainDefLifecycleActionAllowed(virDomainLifecycle type, return true; case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY: case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART: + case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE_RUNNING: break; } break; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index b8283f129e..f091c87702 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -4973,6 +4973,7 @@ destroy: The domain is cleaned up restart: A new domain is started in place of the old one preserve: The domain will remain in memory until it is destroyed manually + preserve-running: Keep the domain as is, let the guest handle the crash. rename-restart: a variant of the previous one but where the old domain is renamed before being saved to allow a restart coredump-destroy: The crashed domain's core will be dumped, and then the @@ -4989,6 +4990,7 @@ rename-restart coredump-destroy coredump-restart + preserve-running