Re: [libvirt] [PATCH 4/4] xenconfig: Add support for max_grant_frames

2019-03-12 Thread Daniel P . Berrangé
On Fri, Mar 08, 2019 at 04:05:58PM -0700, Jim Fehlig wrote:
> Add support in the domXML<->native config converter for
> max_grant_frames. Include a test for the conversion.
> 
> Signed-off-by: Jim Fehlig 
> ---
>  src/xenconfig/xen_xl.c| 56 +++
>  tests/xlconfigdata/test-max-gntframes.cfg | 13 ++
>  tests/xlconfigdata/test-max-gntframes.xml | 32 +
>  tests/xlconfigtest.c  |  4 ++
>  4 files changed, 105 insertions(+)
> 

> diff --git a/tests/xlconfigdata/test-max-gntframes.xml 
> b/tests/xlconfigdata/test-max-gntframes.xml
> new file mode 100644
> index 00..de7c1c09b2
> --- /dev/null
> +++ b/tests/xlconfigdata/test-max-gntframes.xml
> @@ -0,0 +1,32 @@
> +
> +  XenGuest1
> +  45b60f51-88a9-47a8-a3b3-5e66d71b2283
> +  524288
> +  524288
> +  1
> +  /usr/bin/pygrub
> +  
> +linux
> +  
> +  
> +  preserve
> +  restart
> +  preserve
> +  
> +
> +  
> +  
> +  
> +
> +

Same note about  coming first

> +
> +  
> +
> +
> +  
> +
> +
> +
> +
> +  
> +

Reviewed-by: Daniel P. Berrangé 


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

[libvirt] [PATCH 4/4] xenconfig: Add support for max_grant_frames

2019-03-08 Thread Jim Fehlig
Add support in the domXML<->native config converter for
max_grant_frames. Include a test for the conversion.

Signed-off-by: Jim Fehlig 
---
 src/xenconfig/xen_xl.c| 56 +++
 tests/xlconfigdata/test-max-gntframes.cfg | 13 ++
 tests/xlconfigdata/test-max-gntframes.xml | 32 +
 tests/xlconfigtest.c  |  4 ++
 4 files changed, 105 insertions(+)

diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index 2796749a6c..ca094d30c2 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -607,6 +607,34 @@ xenParseXLVnuma(virConfPtr conf,
 }
 #endif
 
+#ifdef LIBXL_HAVE_BUILDINFO_GRANT_LIMITS
+static int
+xenParseXLGntLimits(virConfPtr conf, virDomainDefPtr def)
+{
+unsigned long max_gntframes;
+int ctlr_idx;
+virDomainControllerDefPtr xenbus_ctlr;
+
+if (xenConfigGetULong(conf, "max_grant_frames", _gntframes, 0) < 0)
+return -1;
+
+if (max_gntframes <= 0)
+return 0;
+
+ctlr_idx = virDomainControllerFindByType(def, 
VIR_DOMAIN_CONTROLLER_TYPE_XENBUS);
+if (ctlr_idx == -1)
+xenbus_ctlr = virDomainDefAddController(def, 
VIR_DOMAIN_CONTROLLER_TYPE_XENBUS, -1, -1);
+else
+xenbus_ctlr = def->controllers[ctlr_idx];
+
+if (xenbus_ctlr == NULL)
+return -1;
+
+xenbus_ctlr->opts.xenbusopts.maxGrantFrames = max_gntframes;
+return 0;
+}
+#endif
+
 static int
 xenParseXLDiskSrc(virDomainDiskDefPtr disk, char *srcstr)
 {
@@ -1165,6 +1193,11 @@ xenParseXL(virConfPtr conf,
 goto cleanup;
 #endif
 
+#ifdef LIBXL_HAVE_BUILDINFO_GRANT_LIMITS
+if (xenParseXLGntLimits(conf, def) < 0)
+goto cleanup;
+#endif
+
 if (xenParseXLCPUID(conf, def) < 0)
 goto cleanup;
 
@@ -1517,6 +1550,24 @@ xenFormatXLDomainVnuma(virConfPtr conf,
 }
 #endif
 
+#ifdef LIBXL_HAVE_BUILDINFO_GRANT_LIMITS
+static int
+xenFormatXLGntLimits(virConfPtr conf, virDomainDefPtr def)
+{
+size_t i;
+
+for (i = 0; i < def->ncontrollers; i++) {
+if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_XENBUS &&
+def->controllers[i]->opts.xenbusopts.maxGrantFrames > 0) {
+if (xenConfigSetInt(conf, "max_grant_frames",
+
def->controllers[i]->opts.xenbusopts.maxGrantFrames) < 0)
+return -1;
+}
+}
+return 0;
+}
+#endif
+
 static char *
 xenFormatXLDiskSrcNet(virStorageSourcePtr src)
 {
@@ -2166,6 +2217,11 @@ xenFormatXL(virDomainDefPtr def, virConnectPtr conn)
 goto cleanup;
 #endif
 
+#ifdef LIBXL_HAVE_BUILDINFO_GRANT_LIMITS
+if (xenFormatXLGntLimits(conf, def) < 0)
+goto cleanup;
+#endif
+
 if (xenFormatXLDomainDisks(conf, def) < 0)
 goto cleanup;
 
diff --git a/tests/xlconfigdata/test-max-gntframes.cfg 
b/tests/xlconfigdata/test-max-gntframes.cfg
new file mode 100644
index 00..7235b0d035
--- /dev/null
+++ b/tests/xlconfigdata/test-max-gntframes.cfg
@@ -0,0 +1,13 @@
+name = "XenGuest1"
+uuid = "45b60f51-88a9-47a8-a3b3-5e66d71b2283"
+maxmem = 512
+memory = 512
+vcpus = 1
+localtime = 0
+on_poweroff = "preserve"
+on_reboot = "restart"
+on_crash = "preserve"
+vif = [ "mac=5a:36:0e:be:00:09" ]
+bootloader = "/usr/bin/pygrub"
+max_grant_frames = 64
+disk = [ 
"format=qcow2,vdev=xvda,access=rw,backendtype=qdisk,target=/var/lib/xen/images/debian/disk.qcow2"
 ]
diff --git a/tests/xlconfigdata/test-max-gntframes.xml 
b/tests/xlconfigdata/test-max-gntframes.xml
new file mode 100644
index 00..de7c1c09b2
--- /dev/null
+++ b/tests/xlconfigdata/test-max-gntframes.xml
@@ -0,0 +1,32 @@
+
+  XenGuest1
+  45b60f51-88a9-47a8-a3b3-5e66d71b2283
+  524288
+  524288
+  1
+  /usr/bin/pygrub
+  
+linux
+  
+  
+  preserve
+  restart
+  preserve
+  
+
+  
+  
+  
+
+
+
+  
+
+
+  
+
+
+
+
+  
+
diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c
index 492bda2e63..9ec54bf71d 100644
--- a/tests/xlconfigtest.c
+++ b/tests/xlconfigtest.c
@@ -299,6 +299,10 @@ mymain(void)
 DO_TEST_FORMAT("fullvirt-direct-kernel-boot-extra", false);
 DO_TEST_FORMAT("fullvirt-direct-kernel-boot-bogus-extra", false);
 #endif
+#ifdef LIBXL_HAVE_BUILDINFO_GRANT_LIMITS
+DO_TEST("max-gntframes");
+#endif
+
 DO_TEST("vif-typename");
 DO_TEST("vif-multi-ip");
 DO_TEST("usb");
-- 
2.20.1

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