]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: configurable delay for shutdown before poweroff
authorDaniel P. Berrangé <berrange@redhat.com>
Thu, 19 Dec 2024 19:13:04 +0000 (19:13 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 20 Mar 2025 14:55:17 +0000 (14:55 +0000)
Allow users to control how many seconds libvirt waits for QEMU
shutdown before force powering off a guest.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/qemu/libvirtd_qemu.aug
src/qemu/qemu.conf.in
src/qemu/qemu_conf.c
src/qemu/qemu_conf.h
src/qemu/qemu_driver.c
src/qemu/test_libvirtd_qemu.aug.in

index b2b36161951617a5a61047563834c47c862980eb..7f47bbd1f13d79295a0dbde7244ef1dcd54f173e 100644 (file)
@@ -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"
index a948b8c07e23db7b8d5d27e583a95cc6101291de..fbb6fbf009dc6f5814382528967e874bee895c16 100644 (file)
 # 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
index 23b2e34cb3ac40edc04906ee542d28770aff67e7..6fbc42bf1fe426a3ff6ca54a7f9b9b3af53c78ec 100644 (file)
@@ -763,6 +763,10 @@ virQEMUDriverConfigLoadSaveEntry(virQEMUDriverConfig *cfg,
         cfg->autoShutdownPoweroff = autoShutdownVal;
     }
 
+    if (virConfGetValueUInt(conf, "auto_shutdown_wait",
+                            &cfg->autoShutdownWait) < 0)
+        return -1;
+
     return 0;
 }
 
index 5df9f6501e08ac23c4611322d11c2e9fcf755485..d0c7fe8ccb240f90b6441e124f485747b6b48d37 100644 (file)
@@ -215,6 +215,7 @@ struct _virQEMUDriverConfig {
     virDomainDriverAutoShutdownScope autoShutdownTrySave;
     virDomainDriverAutoShutdownScope autoShutdownTryShutdown;
     virDomainDriverAutoShutdownScope autoShutdownPoweroff;
+    unsigned int autoShutdownWait;
 
     char *lockManagerName;
 
index 8f69d0ec9ce8c5c28b79af233827c0d636353c9f..afb97ac1bf305d2721935e2bd8b84df334a6844c 100644 (file)
@@ -969,6 +969,7 @@ qemuStateStop(void)
         .trySave = cfg->autoShutdownTrySave,
         .tryShutdown = cfg->autoShutdownTryShutdown,
         .poweroff = cfg->autoShutdownPoweroff,
+        .waitShutdownSecs = cfg->autoShutdownWait,
     };
 
     virDomainDriverAutoShutdown(&ascfg);
index 0dc42ca27047d708d715da699a5ce9717fd8e33e..57604d5db2b8b16fbdffb6eb7d5e862a1ca3f9b3 100644 (file)
@@ -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" }