[libvirt] [PATCH] libxl: Add support for max_grant_frame setting

Jim Fehlig posted 1 patch 5 years, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20190304230001.18690-1-jfehlig@suse.com
Test syntax-check passed
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(+)
[libvirt] [PATCH] libxl: Add support for max_grant_frame setting
Posted by Jim Fehlig 5 years, 1 month ago
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@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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] libxl: Add support for max_grant_frame setting
Posted by Daniel P. Berrangé 5 years, 1 month ago
On Mon, Mar 04, 2019 at 04:00:01PM -0700, Jim Fehlig wrote:
> 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.

Does the grant frame value have any impact on the live migration
compatibility ? ie if both source and dest host are required to
have identical grant frame values, then it is preferrable to /not/
have this as a host tunable, but only as XML.  You generally don't
want anything affecting mig compatibility in host level configs.

> 
> 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@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(+)

If-only-if this is ok for live migration compat, then 

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] libxl: Add support for max_grant_frame setting
Posted by Jim Fehlig 5 years, 1 month ago
On 3/5/19 3:17 AM, Daniel P. Berrangé wrote:
> On Mon, Mar 04, 2019 at 04:00:01PM -0700, Jim Fehlig wrote:
>> 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.
> 
> Does the grant frame value have any impact on the live migration
> compatibility ? ie if both source and dest host are required to
> have identical grant frame values, then it is preferrable to /not/
> have this as a host tunable, but only as XML.  You generally don't
> want anything affecting mig compatibility in host level configs.

Thanks for the reminder. Yes, grant frame value could have an affect on 
migration. I didn't put much thought into it since Xen has a similar concept in 
their host level config. Difference is, they also support the setting in their 
per-domain config.

So I'm back to figuring out how to model this in XML

https://www.redhat.com/archives/libvir-list/2019-February/msg01218.html

Your opinion would be much appreciated! Thus far my preferred option is the last 
one described in that thread

https://www.redhat.com/archives/libvir-list/2019-March/msg00124.html

Regards,
Jim

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] libxl: Add support for max_grant_frame setting
Posted by Daniel P. Berrangé 5 years, 1 month ago
On Tue, Mar 05, 2019 at 02:42:51PM -0700, Jim Fehlig wrote:
> On 3/5/19 3:17 AM, Daniel P. Berrangé wrote:
> > On Mon, Mar 04, 2019 at 04:00:01PM -0700, Jim Fehlig wrote:
> > > 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.
> > 
> > Does the grant frame value have any impact on the live migration
> > compatibility ? ie if both source and dest host are required to
> > have identical grant frame values, then it is preferrable to /not/
> > have this as a host tunable, but only as XML.  You generally don't
> > want anything affecting mig compatibility in host level configs.
> 
> Thanks for the reminder. Yes, grant frame value could have an affect on
> migration. I didn't put much thought into it since Xen has a similar concept
> in their host level config. Difference is, they also support the setting in
> their per-domain config.
> 
> So I'm back to figuring out how to model this in XML
> 
> https://www.redhat.com/archives/libvir-list/2019-February/msg01218.html
> 
> Your opinion would be much appreciated! Thus far my preferred option is the
> last one described in that thread
> 
> https://www.redhat.com/archives/libvir-list/2019-March/msg00124.html

Yes, I concur with that preference,

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list