When doing managed save of VMs, triggered by OS shutdown, it may
be desirable to control cache usage.
Reviewed-by: Peter Krempa <pkrempa(a)redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/qemu/libvirtd_qemu.aug | 1 +
src/qemu/qemu.conf.in | 8 ++++++++
src/qemu/qemu_conf.c | 3 +++
src/qemu/qemu_conf.h | 1 +
src/qemu/qemu_driver.c | 1 +
src/qemu/test_libvirtd_qemu.aug.in | 1 +
6 files changed, 15 insertions(+)
diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index 8cb1b144b9..9fa6398d8d 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -102,6 +102,7 @@ module Libvirtd_qemu =
| str_entry "auto_shutdown_try_shutdown"
| str_entry "auto_shutdown_poweroff"
| int_entry "auto_shutdown_wait"
+ | bool_entry "auto_save_bypass_cache"
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 5a9bfd90e8..5643e849ad 100644
--- a/src/qemu/qemu.conf.in
+++ b/src/qemu/qemu.conf.in
@@ -689,6 +689,14 @@
# is currently 30 secs)
#auto_shutdown_wait = 30
+# 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
+# avoid using the file system cache when writing any managed state
+# file, but may cause slower operation.
+#
+#auto_save_bypass_cache = 0
+
# 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 d1ae5fa308..6161a3c8d6 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -732,6 +732,9 @@ virQEMUDriverConfigLoadSaveEntry(virQEMUDriverConfig *cfg,
if (virConfGetValueUInt(conf, "auto_shutdown_wait",
&cfg->autoShutdownWait) < 0)
return -1;
+ if (virConfGetValueBool(conf, "auto_save_bypass_cache",
+ &cfg->autoSaveBypassCache) < 0)
+ return -1;
return 0;
}
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index f6fcfe444d..06c917ba3e 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -206,6 +206,7 @@ struct _virQEMUDriverConfig {
virDomainDriverAutoShutdownScope autoShutdownTryShutdown;
virDomainDriverAutoShutdownScope autoShutdownPoweroff;
unsigned int autoShutdownWait;
+ bool autoSaveBypassCache;
char *lockManagerName;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 08e2248852..3932640b79 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -951,6 +951,7 @@ qemuStateStop(void)
.tryShutdown = cfg->autoShutdownTryShutdown,
.poweroff = cfg->autoShutdownPoweroff,
.waitShutdownSecs = cfg->autoShutdownWait,
+ .saveBypassCache = cfg->autoSaveBypassCache,
};
virDomainDriverAutoShutdown(&ascfg);
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index 4c6de31199..65d0c20fe1 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -80,6 +80,7 @@ module Test_libvirtd_qemu =
{ "auto_shutdown_try_shutdown" = "all" }
{ "auto_shutdown_poweroff" = "all" }
{ "auto_shutdown_wait" = "30" }
+{ "auto_save_bypass_cache" = "0" }
{ "hugetlbfs_mount" = "/dev/hugepages" }
{ "bridge_helper" = "qemu-bridge-helper" }
{ "set_process_name" = "1" }
--
2.48.1