Add support in the domXML<->native config converter for max_event_channels. The parser and formater functions for max_grant_frames were reworked to also parse max_event_channels. In doing so the xenbus controller is added earlier in the config parsing, requiring a small adjustment to one of the existing tests. Include a new test for the event channel conversion. Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx> --- src/libxl/xen_xl.c | 57 +++++++++++-------- tests/xlconfigdata/test-max-eventchannels.cfg | 13 +++++ tests/xlconfigdata/test-max-eventchannels.xml | 32 +++++++++++ tests/xlconfigdata/test-usbctrl.xml | 2 +- tests/xlconfigtest.c | 2 + 5 files changed, 80 insertions(+), 26 deletions(-) diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 91b1825399..d40c2e1d8e 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -597,19 +597,12 @@ xenParseXLVnuma(virConfPtr conf, } #endif -#ifdef LIBXL_HAVE_BUILDINFO_GRANT_LIMITS static int -xenParseXLGntLimits(virConfPtr conf, virDomainDefPtr def) +xenParseXLXenbusLimits(virConfPtr conf, virDomainDefPtr def) { - unsigned long max_gntframes; int ctlr_idx; virDomainControllerDefPtr xenbus_ctlr; - - if (xenConfigGetULong(conf, "max_grant_frames", &max_gntframes, 0) < 0) - return -1; - - if (max_gntframes <= 0) - return 0; + unsigned long limit; ctlr_idx = virDomainControllerFindByType(def, VIR_DOMAIN_CONTROLLER_TYPE_XENBUS); if (ctlr_idx == -1) @@ -620,10 +613,20 @@ xenParseXLGntLimits(virConfPtr conf, virDomainDefPtr def) if (xenbus_ctlr == NULL) return -1; - xenbus_ctlr->opts.xenbusopts.maxGrantFrames = max_gntframes; + if (xenConfigGetULong(conf, "max_event_channels", &limit, 0) < 0) + return -1; + if (limit > 0) + xenbus_ctlr->opts.xenbusopts.maxEventChannels = limit; + +#ifdef LIBXL_HAVE_BUILDINFO_GRANT_LIMITS + if (xenConfigGetULong(conf, "max_grant_frames", &limit, 0) < 0) + return -1; + if (limit > 0) + xenbus_ctlr->opts.xenbusopts.maxGrantFrames = limit; +#endif + return 0; } -#endif static int xenParseXLDiskSrc(virDomainDiskDefPtr disk, char *srcstr) @@ -1180,10 +1183,8 @@ xenParseXL(virConfPtr conf, goto cleanup; #endif -#ifdef LIBXL_HAVE_BUILDINFO_GRANT_LIMITS - if (xenParseXLGntLimits(conf, def) < 0) + if (xenParseXLXenbusLimits(conf, def) < 0) goto cleanup; -#endif if (xenParseXLCPUID(conf, def) < 0) goto cleanup; @@ -1532,23 +1533,31 @@ xenFormatXLDomainVnuma(virConfPtr conf, } #endif -#ifdef LIBXL_HAVE_BUILDINFO_GRANT_LIMITS static int -xenFormatXLGntLimits(virConfPtr conf, virDomainDefPtr def) +xenFormatXLXenbusLimits(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; + if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_XENBUS) { + if (def->controllers[i]->opts.xenbusopts.maxEventChannels > 0) { + if (xenConfigSetInt(conf, "max_event_channels", + def->controllers[i]->opts.xenbusopts.maxEventChannels) < 0) + return -1; + } + +#ifdef LIBXL_HAVE_BUILDINFO_GRANT_LIMITS + if (def->controllers[i]->opts.xenbusopts.maxGrantFrames > 0) { + if (xenConfigSetInt(conf, "max_grant_frames", + def->controllers[i]->opts.xenbusopts.maxGrantFrames) < 0) + return -1; + } +#endif } } + return 0; } -#endif static char * xenFormatXLDiskSrcNet(virStorageSourcePtr src) @@ -2191,10 +2200,8 @@ xenFormatXL(virDomainDefPtr def, virConnectPtr conn) return NULL; #endif -#ifdef LIBXL_HAVE_BUILDINFO_GRANT_LIMITS - if (xenFormatXLGntLimits(conf, def) < 0) + if (xenFormatXLXenbusLimits(conf, def) < 0) return NULL; -#endif if (xenFormatXLDomainDisks(conf, def) < 0) return NULL; diff --git a/tests/xlconfigdata/test-max-eventchannels.cfg b/tests/xlconfigdata/test-max-eventchannels.cfg new file mode 100644 index 0000000000..6794d6e318 --- /dev/null +++ b/tests/xlconfigdata/test-max-eventchannels.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_event_channels = 2047 +disk = [ "format=qcow2,vdev=xvda,access=rw,backendtype=qdisk,target=/var/lib/xen/images/debian/disk.qcow2" ] diff --git a/tests/xlconfigdata/test-max-eventchannels.xml b/tests/xlconfigdata/test-max-eventchannels.xml new file mode 100644 index 0000000000..3ee371a002 --- /dev/null +++ b/tests/xlconfigdata/test-max-eventchannels.xml @@ -0,0 +1,32 @@ +<domain type='xen'> + <name>XenGuest1</name> + <uuid>45b60f51-88a9-47a8-a3b3-5e66d71b2283</uuid> + <memory unit='KiB'>524288</memory> + <currentMemory unit='KiB'>524288</currentMemory> + <vcpu placement='static'>1</vcpu> + <bootloader>/usr/bin/pygrub</bootloader> + <os> + <type arch='x86_64' machine='xenpv'>linux</type> + </os> + <clock offset='utc' adjustment='reset'/> + <on_poweroff>preserve</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>preserve</on_crash> + <devices> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2'/> + <source file='/var/lib/xen/images/debian/disk.qcow2'/> + <target dev='xvda' bus='xen'/> + </disk> + <controller type='xenbus' index='0' maxEventChannels='2047'/> + <interface type='ethernet'> + <mac address='5a:36:0e:be:00:09'/> + </interface> + <console type='pty'> + <target type='xen' port='0'/> + </console> + <input type='mouse' bus='xen'/> + <input type='keyboard' bus='xen'/> + <memballoon model='xen'/> + </devices> +</domain> diff --git a/tests/xlconfigdata/test-usbctrl.xml b/tests/xlconfigdata/test-usbctrl.xml index 3fadd7a8cf..6bf8c2d1d9 100644 --- a/tests/xlconfigdata/test-usbctrl.xml +++ b/tests/xlconfigdata/test-usbctrl.xml @@ -18,8 +18,8 @@ <source file='/var/lib/xen/images/debian/disk.qcow2'/> <target dev='xvda' bus='xen'/> </disk> - <controller type='usb' index='0' model='qusb2' ports='6'/> <controller type='xenbus' index='0'/> + <controller type='usb' index='0' model='qusb2' ports='6'/> <interface type='ethernet'> <mac address='5a:36:0e:be:00:09'/> </interface> diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index 4e4b28cd34..8faef16ddf 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -294,6 +294,8 @@ mymain(void) DO_TEST("max-gntframes"); #endif + DO_TEST("max-eventchannels"); + DO_TEST("vif-typename"); DO_TEST("vif-multi-ip"); DO_TEST("usb"); -- 2.26.0