[PATCH 0/3] libxl: Add support for max_event_channels

This series implements support Xen's max_event_channels setting as proposed in this thread https://www.redhat.com/archives/libvir-list/2020-April/msg00376.html See the individual patches for details. Jim Fehlig (3): conf: Add a new xenbus controller option for event channels libxl: Add support for max_event_channels xenconfig: Add support for max_event_channels docs/formatdomain.html.in | 8 +- docs/schemas/domaincommon.rng | 5 ++ src/conf/domain_conf.c | 15 ++++ src/conf/domain_conf.h | 1 + src/libxl/libxl_conf.c | 14 +-- src/libxl/xen_xl.c | 57 ++++++------ .../max-eventchannels-hvm.json | 90 +++++++++++++++++++ .../max-eventchannels-hvm.xml | 37 ++++++++ tests/libxlxml2domconfigtest.c | 2 + tests/xlconfigdata/test-max-eventchannels.cfg | 13 +++ tests/xlconfigdata/test-max-eventchannels.xml | 32 +++++++ tests/xlconfigdata/test-usbctrl.xml | 2 +- tests/xlconfigtest.c | 2 + 13 files changed, 245 insertions(+), 33 deletions(-) create mode 100644 tests/libxlxml2domconfigdata/max-eventchannels-hvm.json create mode 100644 tests/libxlxml2domconfigdata/max-eventchannels-hvm.xml create mode 100644 tests/xlconfigdata/test-max-eventchannels.cfg create mode 100644 tests/xlconfigdata/test-max-eventchannels.xml -- 2.26.0

Event channels are like PV interrupts and in conjuction with grant frames form a data transfer mechanism for PV drivers. They are also used for inter-processor interrupts. Guests with a large number of vcpus and/or many PV devices many need to increase the maximum default value of 1023. For this reason the native Xen config format supports the 'max_event_channels' setting. See xl.cfg(5) man page for more details. Similar to the existing maxGrantFrames option, add a new xenbus controller option 'maxEventChannels', allowing to adjust the maximum value via libvirt. Signed-off-by: Jim Fehlig <jfehlig@suse.com> --- docs/formatdomain.html.in | 8 ++++++-- docs/schemas/domaincommon.rng | 5 +++++ src/conf/domain_conf.c | 15 +++++++++++++++ src/conf/domain_conf.h | 1 + 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index d56600dc18..eabb7b6ece 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4454,7 +4454,7 @@ <driver iothread='4'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/> </controller> - <controller type='xenbus' maxGrantFrames='64'/> + <controller type='xenbus' maxGrantFrames='64' maxEventChannels='2047'/> ... </devices> ...</pre> @@ -4514,7 +4514,11 @@ <dd><span class="since">Since 5.2.0</span>, the <code>xenbus</code> controller has an optional attribute <code>maxGrantFrames</code>, which specifies the maximum number of grant frames the controller - makes available for connected devices.</dd> + makes available for connected devices. + <span class="since">Since 6.3.0</span>, the xenbus controller + supports the optional <code>maxEventChannels</code> attribute, + which specifies maximum number of event channels (PV interrupts) + that can be used by the guest.</dd> </dl> <p> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index dcf2e09db8..d0dcab9059 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2548,6 +2548,11 @@ <ref name="unsignedInt"/> </attribute> </optional> + <optional> + <attribute name="maxEventChannels"> + <ref name="unsignedInt"/> + </attribute> + </optional> </group> </choice> <optional> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6ad7552bde..0a2aa53264 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2252,6 +2252,7 @@ virDomainControllerDefNew(virDomainControllerType type) break; case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: def->opts.xenbusopts.maxGrantFrames = -1; + def->opts.xenbusopts.maxEventChannels = -1; break; case VIR_DOMAIN_CONTROLLER_TYPE_IDE: case VIR_DOMAIN_CONTROLLER_TYPE_FDC: @@ -11344,6 +11345,7 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt, break; case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: { g_autofree char *gntframes = virXMLPropString(node, "maxGrantFrames"); + g_autofree char *eventchannels = virXMLPropString(node, "maxEventChannels"); if (gntframes) { int r = virStrToLong_i(gntframes, NULL, 10, @@ -11354,6 +11356,15 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; } } + if (eventchannels) { + int r = virStrToLong_i(eventchannels, NULL, 10, + &def->opts.xenbusopts.maxEventChannels); + if (r != 0 || def->opts.xenbusopts.maxEventChannels < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid maxEventChannels: %s"), eventchannels); + goto error; + } + } break; } @@ -25286,6 +25297,10 @@ virDomainControllerDefFormat(virBufferPtr buf, virBufferAsprintf(&attrBuf, " maxGrantFrames='%d'", def->opts.xenbusopts.maxGrantFrames); } + if (def->opts.xenbusopts.maxEventChannels != -1) { + virBufferAsprintf(&attrBuf, " maxEventChannels='%d'", + def->opts.xenbusopts.maxEventChannels); + } break; default: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 024f692053..089d600061 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -730,6 +730,7 @@ struct _virDomainUSBControllerOpts { struct _virDomainXenbusControllerOpts { int maxGrantFrames; /* -1 == undef */ + int maxEventChannels; /* -1 == undef */ }; /* Stores the virtual disk controller configuration */ -- 2.26.0

On Wed, Apr 08, 2020 at 02:08:53PM -0600, Jim Fehlig wrote:
Event channels are like PV interrupts and in conjuction with grant frames form a data transfer mechanism for PV drivers. They are also used for inter-processor interrupts. Guests with a large number of vcpus and/or many PV devices many need to increase the maximum default value of 1023. For this reason the native Xen config format supports the 'max_event_channels' setting. See xl.cfg(5) man page for more details.
Similar to the existing maxGrantFrames option, add a new xenbus controller option 'maxEventChannels', allowing to adjust the maximum value via libvirt.
Signed-off-by: Jim Fehlig <jfehlig@suse.com> --- docs/formatdomain.html.in | 8 ++++++-- docs/schemas/domaincommon.rng | 5 +++++ src/conf/domain_conf.c | 15 +++++++++++++++ src/conf/domain_conf.h | 1 + 4 files changed, 27 insertions(+), 2 deletions(-)
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 :|

Add support for setting event_channels in libxl domain config object and include a test to check that it is properly converted from XML to libxl domain config. Signed-off-by: Jim Fehlig <jfehlig@suse.com> --- src/libxl/libxl_conf.c | 14 +-- .../max-eventchannels-hvm.json | 90 +++++++++++++++++++ .../max-eventchannels-hvm.xml | 37 ++++++++ tests/libxlxml2domconfigtest.c | 2 + 4 files changed, 138 insertions(+), 5 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index be5fc505fe..b3f67f817a 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -380,13 +380,17 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, b_info->max_memkb = virDomainDefGetMemoryInitial(def); b_info->target_memkb = def->mem.cur_balloon; -#ifdef LIBXL_HAVE_BUILDINFO_GRANT_LIMITS for (i = 0; i < def->ncontrollers; i++) { - if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_XENBUS && - def->controllers[i]->opts.xenbusopts.maxGrantFrames > 0) - b_info->max_grant_frames = def->controllers[i]->opts.xenbusopts.maxGrantFrames; - } + if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_XENBUS) { + if (def->controllers[i]->opts.xenbusopts.maxEventChannels > 0) + b_info->event_channels = def->controllers[i]->opts.xenbusopts.maxEventChannels; + +#ifdef LIBXL_HAVE_BUILDINFO_GRANT_LIMITS + if (def->controllers[i]->opts.xenbusopts.maxGrantFrames > 0) + b_info->max_grant_frames = def->controllers[i]->opts.xenbusopts.maxGrantFrames; #endif + } + } if (hvm || pvh) { if (caps && diff --git a/tests/libxlxml2domconfigdata/max-eventchannels-hvm.json b/tests/libxlxml2domconfigdata/max-eventchannels-hvm.json new file mode 100644 index 0000000000..d5b351beb5 --- /dev/null +++ b/tests/libxlxml2domconfigdata/max-eventchannels-hvm.json @@ -0,0 +1,90 @@ +{ + "c_info": { + "type": "hvm", + "name": "test-hvm", + "uuid": "2147d599-9cc6-c0dc-92ab-4064b5446e9b" + }, + "b_info": { + "max_vcpus": 4, + "avail_vcpus": [ + 0, + 1, + 2, + 3 + ], + "max_memkb": 1048576, + "target_memkb": 1048576, + "video_memkb": 8192, + "shadow_memkb": 12288, + "event_channels": 2047, + "device_model_version": "qemu_xen", + "device_model": "/bin/true", + "sched_params": { + + }, + "type.hvm": { + "pae": "True", + "apic": "True", + "acpi": "True", + "vga": { + "kind": "cirrus" + }, + "vnc": { + "enable": "True", + "listen": "0.0.0.0", + "findunused": "False" + }, + "sdl": { + "enable": "False" + }, + "spice": { + + }, + "boot": "c", + "rdm": { + + } + }, + "arch_arm": { + + } + }, + "disks": [ + { + "pdev_path": "/var/lib/xen/images/test-hvm.img", + "vdev": "hda", + "backend": "qdisk", + "format": "raw", + "removable": 1, + "readwrite": 1 + } + ], + "nics": [ + { + "devid": 0, + "mac": "00:16:3e:66:12:b4", + "bridge": "br0", + "script": "/etc/xen/scripts/vif-bridge", + "nictype": "vif_ioemu" + } + ], + "vfbs": [ + { + "devid": -1, + "vnc": { + "enable": "True", + "listen": "0.0.0.0", + "findunused": "False" + }, + "sdl": { + "enable": "False" + } + } + ], + "vkbs": [ + { + "devid": -1 + } + ], + "on_reboot": "restart" +} diff --git a/tests/libxlxml2domconfigdata/max-eventchannels-hvm.xml b/tests/libxlxml2domconfigdata/max-eventchannels-hvm.xml new file mode 100644 index 0000000000..97b1440a5e --- /dev/null +++ b/tests/libxlxml2domconfigdata/max-eventchannels-hvm.xml @@ -0,0 +1,37 @@ +<domain type='xen'> + <name>test-hvm</name> + <description>None</description> + <uuid>2147d599-9cc6-c0dc-92ab-4064b5446e9b</uuid> + <memory>1048576</memory> + <currentMemory>1048576</currentMemory> + <vcpu>4</vcpu> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <clock offset='utc'/> + <os> + <type>hvm</type> + <loader>/usr/lib/xen/boot/hvmloader</loader> + <boot dev='hd'/> + </os> + <features> + <apic/> + <acpi/> + <pae/> + </features> + <devices> + <emulator>/bin/true</emulator> + <disk type='file' device='disk'> + <driver name='qemu'/> + <source file='/var/lib/xen/images/test-hvm.img'/> + <target dev='hda'/> + </disk> + <controller type='xenbus' maxEventChannels='2047'/> + <interface type='bridge'> + <source bridge='br0'/> + <mac address='00:16:3e:66:12:b4'/> + <script path='/etc/xen/scripts/vif-bridge'/> + </interface> + <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'/> + </devices> +</domain> diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c index 893b48d282..a2ef9bed0b 100644 --- a/tests/libxlxml2domconfigtest.c +++ b/tests/libxlxml2domconfigtest.c @@ -202,6 +202,8 @@ mymain(void) DO_TEST("max-gntframes-hvm"); # endif + DO_TEST("max-eventchannels-hvm"); + unlink("libxl-driver.log"); testXLFreeDriver(driver); -- 2.26.0

On Wed, Apr 08, 2020 at 02:08:54PM -0600, Jim Fehlig wrote:
Add support for setting event_channels in libxl domain config object and include a test to check that it is properly converted from XML to libxl domain config.
Signed-off-by: Jim Fehlig <jfehlig@suse.com> --- src/libxl/libxl_conf.c | 14 +-- .../max-eventchannels-hvm.json | 90 +++++++++++++++++++ .../max-eventchannels-hvm.xml | 37 ++++++++ tests/libxlxml2domconfigtest.c | 2 + 4 files changed, 138 insertions(+), 5 deletions(-)
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 :|

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@suse.com> --- 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

On Wed, Apr 08, 2020 at 02:08:55PM -0600, Jim Fehlig wrote:
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@suse.com> --- 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(-)
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 :|
participants (2)
-
Daniel P. Berrangé
-
Jim Fehlig