[libvirt] [PATCH 0/2] Add support for ioeventfd for virtio-scsi

This series is based on top of Laine's v3 of Add new PCIe controllers. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1150484 Martin Kletzander (2): conf: Add ioeventfd option for controllers qemu: Enable ioeventfd usage for virtio-scsi controllers docs/formatdomain.html.in | 8 ++++++ docs/schemas/domaincommon.rng | 3 +++ src/conf/domain_conf.c | 19 ++++++++++++-- src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 7 ++++++ .../qemuxml2argv-disk-virtio-scsi-ioeventfd.xml | 29 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 3 +++ tests/qemuxml2xmltest.c | 1 + 8 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ioeventfd.xml -- 2.4.6

This will be used with a virtio-scsi controller later on. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- docs/formatdomain.html.in | 8 ++++++ docs/schemas/domaincommon.rng | 3 +++ src/conf/domain_conf.c | 19 ++++++++++++-- src/conf/domain_conf.h | 1 + .../qemuxml2argv-disk-virtio-scsi-ioeventfd.xml | 29 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 6 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ioeventfd.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 2f61ac826726..3eb83d419806 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2998,6 +2998,14 @@ a sector is 512 bytes. <span class="since">Since 1.2.7 (QEMU and KVM only)</span> </dd> + <dt><code>ioeventfd</code></dt> + <dd> + The optional <code>ioeventfd</code> attribute specifies + whether the controller should use + <a href='https://patchwork.kernel.org/patch/43390/'> + I/O asynchronous handling</a> or not. Accepted values are + "on" and "off". <span class="since">Since 1.2.18</span> + </dd> </dl> <p> USB companion controllers have an optional diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ab02d14f8ee7..043c9757d268 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1832,6 +1832,9 @@ <ref name="unsignedInt"/> </attribute> </optional> + <optional> + <ref name="ioeventfd"/> + </optional> </element> </optional> </interleave> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0cf111a2522d..34695a21b872 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7788,6 +7788,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, char *chassisNr = NULL; char *chassis = NULL; char *port = NULL; + char *ioeventfd = NULL; xmlNodePtr saved = ctxt->node; int rc; @@ -7831,6 +7832,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, queues = virXMLPropString(cur, "queues"); cmd_per_lun = virXMLPropString(cur, "cmd_per_lun"); max_sectors = virXMLPropString(cur, "max_sectors"); + ioeventfd = virXMLPropString(cur, "ioeventfd"); } else if (xmlStrEqual(cur->name, BAD_CAST "model")) { if (processedModel) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -7874,6 +7876,12 @@ virDomainControllerDefParseXML(xmlNodePtr node, goto error; } + if (ioeventfd && (def->ioeventfd = virTristateSwitchTypeFromString(ioeventfd)) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Malformed 'ioeventfd' value %s'"), max_sectors); + goto error; + } + if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_USB && def->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) { VIR_DEBUG("Ignoring device address for none model usb controller"); @@ -8060,6 +8068,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, VIR_FREE(queues); VIR_FREE(cmd_per_lun); VIR_FREE(max_sectors); + VIR_FREE(ioeventfd); VIR_FREE(modelName); VIR_FREE(chassisNr); VIR_FREE(chassis); @@ -19126,7 +19135,7 @@ virDomainControllerDefFormat(virBufferPtr buf, break; } - if (pciModel || pciTarget || + if (pciModel || pciTarget || def->ioeventfd || def->queues || def->cmd_per_lun || def->max_sectors || virDomainDeviceInfoNeedsFormat(&def->info, flags) || pcihole64) { virBufferAddLit(buf, ">\n"); @@ -19157,7 +19166,8 @@ virDomainControllerDefFormat(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); } - if (def->queues || def->cmd_per_lun || def->max_sectors) { + if (def->queues || def->cmd_per_lun || + def->max_sectors || def->ioeventfd) { virBufferAddLit(buf, "<driver"); if (def->queues) virBufferAsprintf(buf, " queues='%u'", def->queues); @@ -19167,6 +19177,11 @@ virDomainControllerDefFormat(virBufferPtr buf, if (def->max_sectors) virBufferAsprintf(buf, " max_sectors='%u'", def->max_sectors); + + if (def->ioeventfd) { + virBufferAsprintf(buf, " ioeventfd='%s'", + virTristateSwitchTypeToString(def->ioeventfd)); + } virBufferAddLit(buf, "/>\n"); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 440d74d971db..3d02eb387c41 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -840,6 +840,7 @@ struct _virDomainControllerDef { unsigned int queues; unsigned int cmd_per_lun; unsigned int max_sectors; + int ioeventfd; /* enum virTristateBool */ union { virDomainVirtioSerialOpts vioserial; virDomainPCIControllerOpts pciopts; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ioeventfd.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ioeventfd.xml new file mode 100644 index 000000000000..f4487eb849c5 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ioeventfd.xml @@ -0,0 +1,29 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>8</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='sdb' bus='scsi'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'/> + <controller type='scsi' index='0' model='virtio-scsi'> + <driver ioeventfd='on'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index b261db2bcff1..08923faa8458 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -420,6 +420,7 @@ mymain(void) DO_TEST("disk-virtio-scsi-num_queues"); DO_TEST("disk-virtio-scsi-cmd_per_lun"); DO_TEST("disk-virtio-scsi-max_sectors"); + DO_TEST("disk-virtio-scsi-ioeventfd"); DO_TEST("disk-scsi-megasas"); DO_TEST_DIFFERENT("disk-mirror-old"); DO_TEST_FULL("disk-mirror", false, WHEN_ACTIVE); -- 2.4.6

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1150484 Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/qemu/qemu_command.c | 7 +++++++ tests/qemuxml2argvtest.c | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 11037c4c29ca..4b546d69279d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4605,6 +4605,11 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef, _("'max_sectors' is only supported by virtio-scsi controller")); return NULL; } + if (def->ioeventfd) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'ioeventfd' is only supported by virtio-scsi controller")); + return NULL; + } } switch (def->type) { @@ -4903,6 +4908,8 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef, if (def->max_sectors) virBufferAsprintf(&buf, ",max_sectors=%u", def->max_sectors); + qemuBuildIoEventFdStr(&buf, def->ioeventfd, qemuCaps); + if (qemuBuildDeviceAddressStr(&buf, domainDef, &def->info, qemuCaps) < 0) goto error; diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index e743bbebe844..05732785c843 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -877,6 +877,9 @@ mymain(void) DO_TEST("disk-virtio-scsi-max_sectors", QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI); + DO_TEST("disk-virtio-scsi-ioeventfd", + QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_VIRTIO_IOEVENTFD, QEMU_CAPS_VIRTIO_SCSI); DO_TEST("disk-scsi-megasas", QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_SCSI_MEGASAS); -- 2.4.6

On Sun, Jul 26, 2015 at 08:52:04PM +0200, Martin Kletzander wrote:
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1150484
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/qemu/qemu_command.c | 7 +++++++ tests/qemuxml2argvtest.c | 3 +++
I forgot to do a 'git add' on the new file, this needs to be considered squashed in during review (it's already squashed in my repo): diff --git c/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ioeventfd.args i/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ioeventfd.args new file mode 100644 index 000000000000..1c5318935512 --- /dev/null +++ i/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-ioeventfd.args @@ -0,0 +1,9 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M pc -m 214 -smp 8 -nographic -nodefconfig -nodefaults \ +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-device virtio-scsi-pci,id=scsi0,ioeventfd=on,bus=pci.0,addr=0x3 \ +-usb \ +-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-0-0-0 \ +-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\ +drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 -- Martin
participants (1)
-
Martin Kletzander