Xen 4.10 introduced the max_grant_frames xl config setting, which
can be set globally in xl.conf(5) or per-domain in xl.cfg(5).
max_grant_frames specifies the maximum number of grant frames the
domain is allowed to have, which in turn controls the number of
pages the domain can share.
This patch adds support for setting max_grant_frames on a global
level in libxl.conf. Per-domain support via domXML can be provided
in a future patch.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libvirtd_libxl.aug | 2 ++
src/libxl/libxl.conf | 8 ++++++++
src/libxl/libxl_conf.c | 9 +++++++++
src/libxl/libxl_conf.h | 2 ++
src/libxl/test_libvirtd_libxl.aug.in | 1 +
5 files changed, 22 insertions(+)
diff --git a/src/libxl/libvirtd_libxl.aug b/src/libxl/libvirtd_libxl.aug
index 58b9af3707..1c3e2719fc 100644
--- a/src/libxl/libvirtd_libxl.aug
+++ b/src/libxl/libvirtd_libxl.aug
@@ -29,6 +29,7 @@ module Libvirtd_libxl =
let keepalive_interval_entry = int_entry "keepalive_interval"
let keepalive_count_entry = int_entry "keepalive_count"
let nested_hvm_entry = bool_entry "nested_hvm"
+ let max_grant_frames_entry = int_entry "max_grant_frames"
(* Each entry in the config is one of the following ... *)
let entry = autoballoon_entry
@@ -36,6 +37,7 @@ module Libvirtd_libxl =
| keepalive_interval_entry
| keepalive_count_entry
| nested_hvm_entry
+ | max_grant_frames_entry
let comment = [ label "#comment" . del /#[ \t]*/ "# " . store
/([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
let empty = [ label "#empty" . eol ]
diff --git a/src/libxl/libxl.conf b/src/libxl/libxl.conf
index 72825a71c5..12d7abeda6 100644
--- a/src/libxl/libxl.conf
+++ b/src/libxl/libxl.conf
@@ -49,3 +49,11 @@
# element.
# By default it is disabled.
#nested_hvm = 0
+
+# Xen domains can grant other domains access to its memory pages, which is
+# most commonly used for the operation of paravirtualized devices.
+# max_grant_frames was introduced in Xen 4.10 and can be used to specify a
+# default value for the maximum number of grant frames each domain started
+# by libvirt is allowed to have. The default value is 32.
+#
+#max_grant_frames = 32
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index c769050ff1..f57ffe1a01 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -393,6 +393,12 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
def->mem.cur_balloon = VIR_ROUND_UP(def->mem.cur_balloon, 1024);
b_info->max_memkb = virDomainDefGetMemoryInitial(def);
b_info->target_memkb = def->mem.cur_balloon;
+
+#ifdef LIBXL_HAVE_BUILDINFO_GRANT_LIMITS
+ if (cfg->max_grant_frames > 0)
+ b_info->max_grant_frames = cfg->max_grant_frames;
+#endif
+
if (hvm || pvh) {
if (caps &&
def->cpu && def->cpu->mode ==
(VIR_CPU_MODE_HOST_PASSTHROUGH)) {
@@ -1888,6 +1894,9 @@ int libxlDriverConfigLoadFile(libxlDriverConfigPtr cfg,
if (virConfGetValueBool(conf, "nested_hvm", &cfg->nested_hvm) <
0)
goto cleanup;
+ if (virConfGetValueUInt(conf, "max_grant_frames",
&cfg->max_grant_frames) < 0)
+ goto cleanup;
+
ret = 0;
cleanup:
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index fee94241af..985524f3eb 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -86,6 +86,8 @@ struct _libxlDriverConfig {
bool nested_hvm;
+ unsigned int max_grant_frames;
+
/* Once created, caps are immutable */
virCapsPtr caps;
diff --git a/src/libxl/test_libvirtd_libxl.aug.in b/src/libxl/test_libvirtd_libxl.aug.in
index 372a43f94a..754ddc10f6 100644
--- a/src/libxl/test_libvirtd_libxl.aug.in
+++ b/src/libxl/test_libvirtd_libxl.aug.in
@@ -7,3 +7,4 @@ module Test_libvirtd_libxl =
{ "keepalive_interval" = "5" }
{ "keepalive_count" = "5" }
{ "nested_hvm" = "0" }
+{ "max_grant_frames" = "32" }
--
2.20.1