From: Daniel P. Berrangé Date: Thu, 19 Dec 2024 19:13:04 +0000 (+0000) Subject: qemu: configurable delay for shutdown before poweroff X-Git-Tag: v11.2.0-rc1~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=faa7a082a1f34e28679abc45b8bb8881a01a05e2;p=thirdparty%2Flibvirt.git qemu: configurable delay for shutdown before poweroff Allow users to control how many seconds libvirt waits for QEMU shutdown before force powering off a guest. Reviewed-by: Peter Krempa Signed-off-by: Daniel P. Berrangé --- diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index b2b3616195..7f47bbd1f1 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -106,6 +106,7 @@ module Libvirtd_qemu = | str_entry "auto_shutdown_try_save" | str_entry "auto_shutdown_try_shutdown" | str_entry "auto_shutdown_poweroff" + | int_entry "auto_shutdown_wait" let process_entry = str_entry "hugetlbfs_mount" | str_entry "bridge_helper" diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in index a948b8c07e..fbb6fbf009 100644 --- a/src/qemu/qemu.conf.in +++ b/src/qemu/qemu.conf.in @@ -708,6 +708,12 @@ # set to 'none' for system daemons to avoid dueling actions #auto_shutdown_poweroff = "all" +# How may seconds to wait for running VMs to gracefully shutdown +# when 'auto_shutdown_try_shutdown' is enabled. If set to 0 +# then an arbitrary built-in default value will be used (which +# is currently 30 secs) +#auto_shutdown_wait = 30 + # If provided by the host and a hugetlbfs mount point is configured, # a guest may request huge page backing. When this mount point is # unspecified here, determination of a host mount point in /proc/mounts diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 23b2e34cb3..6fbc42bf1f 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -763,6 +763,10 @@ virQEMUDriverConfigLoadSaveEntry(virQEMUDriverConfig *cfg, cfg->autoShutdownPoweroff = autoShutdownVal; } + if (virConfGetValueUInt(conf, "auto_shutdown_wait", + &cfg->autoShutdownWait) < 0) + return -1; + return 0; } diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 5df9f6501e..d0c7fe8ccb 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -215,6 +215,7 @@ struct _virQEMUDriverConfig { virDomainDriverAutoShutdownScope autoShutdownTrySave; virDomainDriverAutoShutdownScope autoShutdownTryShutdown; virDomainDriverAutoShutdownScope autoShutdownPoweroff; + unsigned int autoShutdownWait; char *lockManagerName; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8f69d0ec9c..afb97ac1bf 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -969,6 +969,7 @@ qemuStateStop(void) .trySave = cfg->autoShutdownTrySave, .tryShutdown = cfg->autoShutdownTryShutdown, .poweroff = cfg->autoShutdownPoweroff, + .waitShutdownSecs = cfg->autoShutdownWait, }; virDomainDriverAutoShutdown(&ascfg); diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in index 0dc42ca270..57604d5db2 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -83,6 +83,7 @@ module Test_libvirtd_qemu = { "auto_shutdown_try_save" = "persistent" } { "auto_shutdown_try_shutdown" = "all" } { "auto_shutdown_poweroff" = "all" } +{ "auto_shutdown_wait" = "30" } { "hugetlbfs_mount" = "/dev/hugepages" } { "bridge_helper" = "qemu-bridge-helper" } { "set_process_name" = "1" }