1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-30 18:50:18 +03:00

qemu: add config to control if auto-shutdown VMs are restored

If shutting down running VMs at host shutdown, it can be useful to
automatically start them again on next boot. This adds a config
parameter 'auto_shutdown_restore', which defaults to enabled, which
leverages the autostart once feature.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2024-12-20 12:55:49 +00:00
parent 7e153492e7
commit da1d0f32d0
6 changed files with 11 additions and 0 deletions

View File

@ -107,6 +107,7 @@ module Libvirtd_qemu =
| str_entry "auto_shutdown_try_shutdown"
| str_entry "auto_shutdown_poweroff"
| int_entry "auto_shutdown_wait"
| bool_entry "auto_shutdown_restore"
| bool_entry "auto_save_bypass_cache"
let process_entry = str_entry "hugetlbfs_mount"

View File

@ -714,6 +714,10 @@
# is currently 30 secs)
#auto_shutdown_wait = 30
# Whether VMs that are automatically powered off or saved during
# host shutdown, should be set to restore on next boot
#auto_shutdown_restore = 1
# When a domain is configured to be auto-saved on shutdown, enabling
# this flag has the same effect as using the VIR_DOMAIN_SAVE_BYPASS_CACHE
# flag with the virDomainManagedSave API. That is, the system will

View File

@ -328,6 +328,7 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged,
cfg->autoShutdownTryShutdown = VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_ALL;
cfg->autoShutdownPoweroff = VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_ALL;
}
cfg->autoShutdownRestore = true;
return g_steal_pointer(&cfg);
}
@ -766,6 +767,8 @@ virQEMUDriverConfigLoadSaveEntry(virQEMUDriverConfig *cfg,
if (virConfGetValueUInt(conf, "auto_shutdown_wait",
&cfg->autoShutdownWait) < 0)
return -1;
if (virConfGetValueBool(conf, "auto_shutdown_restore", &cfg->autoShutdownRestore) < 0)
return -1;
if (virConfGetValueBool(conf, "auto_save_bypass_cache",
&cfg->autoSaveBypassCache) < 0)
return -1;

View File

@ -216,6 +216,7 @@ struct _virQEMUDriverConfig {
virDomainDriverAutoShutdownScope autoShutdownTryShutdown;
virDomainDriverAutoShutdownScope autoShutdownPoweroff;
unsigned int autoShutdownWait;
bool autoShutdownRestore;
bool autoSaveBypassCache;
char *lockManagerName;

View File

@ -971,6 +971,7 @@ qemuStateStop(void)
.poweroff = cfg->autoShutdownPoweroff,
.waitShutdownSecs = cfg->autoShutdownWait,
.saveBypassCache = cfg->autoSaveBypassCache,
.autoRestore = cfg->autoShutdownRestore,
};
virDomainDriverAutoShutdown(&ascfg);

View File

@ -84,6 +84,7 @@ module Test_libvirtd_qemu =
{ "auto_shutdown_try_shutdown" = "all" }
{ "auto_shutdown_poweroff" = "all" }
{ "auto_shutdown_wait" = "30" }
{ "auto_shutdown_restore" = "1" }
{ "auto_save_bypass_cache" = "0" }
{ "hugetlbfs_mount" = "/dev/hugepages" }
{ "bridge_helper" = "qemu-bridge-helper" }