[libvirt] [PATCH v2 0/3] Introduce support for rx_queue_size

v2 of: https://www.redhat.com/archives/libvir-list/2016-August/msg00960.html diff to v1: - rename attribute to rx_queue_size - added more documentation and test cases - Other small nits John found Michal Privoznik (3): conf: Add support for virtio-net.rx_queue_size qemu_capabilities: Introduce virtio-net-*.rx_queue_size qemu: Implement virtio-net rx_queue_size docs/formatdomain.html.in | 16 ++++++++- docs/schemas/domaincommon.rng | 5 +++ src/conf/domain_conf.c | 16 +++++++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_capabilities.c | 3 ++ src/qemu/qemu_capabilities.h | 3 ++ src/qemu/qemu_command.c | 8 +++++ src/qemu/qemu_domain.c | 7 ++++ ...ml2argv-net-virtio-rxqueuesize-invalid-size.xml | 29 +++++++++++++++ .../qemuxml2argv-net-virtio-rxqueuesize.args | 25 +++++++++++++ .../qemuxml2argv-net-virtio-rxqueuesize.xml | 29 +++++++++++++++ tests/qemuxml2argvtest.c | 3 ++ .../qemuxml2xmlout-net-virtio-rxqueuesize.xml | 41 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 14 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize-invalid-size.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize.xml -- 2.8.4

https://bugzilla.redhat.com/show_bug.cgi?id=1366989 QEMU added another virtio-net tunable [1]. It basically allows users to set the size of RX virtio ring. But because virtio-net uses two separate ring buffers to pass data from/to guest they named it explicitly rx_queue_size. We should expose it in our XML too. 1: http://lists.nongnu.org/archive/html/qemu-devel/2016-08/msg02029.html Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- docs/formatdomain.html.in | 16 ++++++++- docs/schemas/domaincommon.rng | 5 +++ src/conf/domain_conf.c | 16 +++++++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_domain.c | 7 ++++ ...ml2argv-net-virtio-rxqueuesize-invalid-size.xml | 29 +++++++++++++++ .../qemuxml2argv-net-virtio-rxqueuesize.xml | 29 +++++++++++++++ tests/qemuxml2argvtest.c | 1 + .../qemuxml2xmlout-net-virtio-rxqueuesize.xml | 41 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 10 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize-invalid-size.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 8c15a73..be19bb9 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4650,7 +4650,7 @@ qemu-kvm -net nic,model=? /dev/null <source network='default'/> <target dev='vnet1'/> <model type='virtio'/> - <b><driver name='vhost' txmode='iothread' ioeventfd='on' event_idx='off' queues='5'> + <b><driver name='vhost' txmode='iothread' ioeventfd='on' event_idx='off' queues='5' rx_queue_size='256'> <host csum='off' gso='off' tso4='off' tso6='off' ecn='off' ufo='off' mrg_rxbuf='off'/> <guest csum='off' tso4='off' tso6='off' ecn='off' ufo='off'/> </driver> @@ -4766,6 +4766,20 @@ qemu-kvm -net nic,model=? /dev/null <span class="since">virtio-net since 1.0.6 (QEMU and KVM only)</span> <span class="since">vhost-user since 1.2.17 (QEMU and KVM only)</span> </dd> + <dt><code>rx_queue_size</code></dt> + <dd> + The optional <code>rx_queue_size</code> attribute controls + the size of virtio ring for each queue as described above. + The default value is hypervisor dependent and may change + across its releases. Moreover, some hypervisors may pose + some restrictions on actual value. For instance, latest + QEMU requires value to be a power of two from [256, 1024] + range. + <span class="since">Since 2.3.0 (QEMU and KVM only)</span> + + <b>In general you should leave this option alone, unless you + are very certain you know what you are doing.</b> + </dd> </dl> <p> Offloading options for the host and guest can be configured using diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 9a7d03e..387121d 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2554,6 +2554,11 @@ </attribute> </optional> <optional> + <attribute name='rx_queue_size'> + <ref name='positiveInteger'/> + </attribute> + </optional> + <optional> <attribute name="txmode"> <choice> <value>iothread</value> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 61f6dbb..05a1227 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8962,6 +8962,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, char *ioeventfd = NULL; char *event_idx = NULL; char *queues = NULL; + char *rx_queue_size = NULL; char *str = NULL; char *filter = NULL; char *internal = NULL; @@ -9134,6 +9135,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, ioeventfd = virXMLPropString(cur, "ioeventfd"); event_idx = virXMLPropString(cur, "event_idx"); queues = virXMLPropString(cur, "queues"); + rx_queue_size = virXMLPropString(cur, "rx_queue_size"); } else if (xmlStrEqual(cur->name, BAD_CAST "filterref")) { if (filter) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -9517,6 +9519,17 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, if (q > 1) def->driver.virtio.queues = q; } + if (rx_queue_size) { + unsigned int q; + if (virStrToLong_uip(rx_queue_size, NULL, 10, &q) < 0) { + virReportError(VIR_ERR_XML_DETAIL, + _("'rx_queue_size' attribute must be positive number: %s"), + rx_queue_size); + goto error; + } + if (q > 1) + def->driver.virtio.rx_queue_size = q; + } if ((str = virXPathString("string(./driver/host/@csum)", ctxt))) { if ((val = virTristateSwitchTypeFromString(str)) <= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -9697,6 +9710,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, VIR_FREE(ioeventfd); VIR_FREE(event_idx); VIR_FREE(queues); + VIR_FREE(rx_queue_size); VIR_FREE(str); VIR_FREE(filter); VIR_FREE(type); @@ -20890,6 +20904,8 @@ virDomainVirtioNetDriverFormat(char **outstr, } if (def->driver.virtio.queues) virBufferAsprintf(&buf, "queues='%u' ", def->driver.virtio.queues); + if (def->driver.virtio.rx_queue_size) + virBufferAsprintf(&buf, "rx_queue_size='%u' ", def->driver.virtio.rx_queue_size); virBufferTrim(&buf, " ", -1); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b889125..3411a67 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -906,6 +906,7 @@ struct _virDomainNetDef { virTristateSwitch ioeventfd; virTristateSwitch event_idx; unsigned int queues; /* Multiqueue virtio-net */ + unsigned int rx_queue_size; struct { virTristateSwitch csum; virTristateSwitch gso; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c1fb771..29ade0e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2475,6 +2475,13 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, "not supported by QEMU")); goto cleanup; } + + if (STREQ_NULLABLE(net->model, "virtio") && + net->driver.virtio.rx_queue_size & (net->driver.virtio.rx_queue_size - 1)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("rx_queue_size has to be a power of two")); + goto cleanup; + } } ret = 0; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize-invalid-size.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize-invalid-size.xml new file mode 100644 index 0000000..d308bc1 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize-invalid-size.xml @@ -0,0 +1,29 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</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='hda' bus='ide'/> + </disk> + <controller type='usb' index='0'/> + <interface type='user'> + <mac address='00:11:22:33:44:55'/> + <model type='virtio'/> + <driver rx_queue_size='511'/> + </interface> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml new file mode 100644 index 0000000..cfb4742 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml @@ -0,0 +1,29 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</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='hda' bus='ide'/> + </disk> + <controller type='usb' index='0'/> + <interface type='user'> + <mac address='00:11:22:33:44:55'/> + <model type='virtio'/> + <driver rx_queue_size='512'/> + </interface> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 39abe72..d0be22d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1043,6 +1043,7 @@ mymain(void) QEMU_CAPS_VIRTIO_S390); DO_TEST("net-virtio-ccw", QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); + DO_TEST_PARSE_ERROR("net-virtio-rxqueuesize-invalid-size", NONE); DO_TEST("net-eth", NONE); DO_TEST("net-eth-ifname", NONE); DO_TEST("net-eth-names", NONE); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize.xml new file mode 100644 index 0000000..5b41936 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize.xml @@ -0,0 +1,41 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</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='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <interface type='user'> + <mac address='00:11:22:33:44:55'/> + <model type='virtio'/> + <driver rx_queue_size='512'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </interface> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 7601a5f..602b600 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -514,6 +514,7 @@ mymain(void) DO_TEST("net-eth-ifname", NONE); DO_TEST("net-eth-hostip", NONE); DO_TEST("net-virtio-network-portgroup", NONE); + DO_TEST("net-virtio-rxqueuesize", NONE); DO_TEST("net-hostdev", NONE); DO_TEST("net-hostdev-vfio", NONE); DO_TEST("net-midonet", NONE); -- 2.8.4

On Wed, Aug 31, 2016 at 05:10:33PM +0200, Michal Privoznik wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=1366989
QEMU added another virtio-net tunable [1]. It basically allows users to set the size of RX virtio ring. But because virtio-net uses two separate ring buffers to pass data from/to guest they named it explicitly rx_queue_size. We should expose it in our XML too.
1: http://lists.nongnu.org/archive/html/qemu-devel/2016-08/msg02029.html
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- docs/formatdomain.html.in | 16 ++++++++- docs/schemas/domaincommon.rng | 5 +++ src/conf/domain_conf.c | 16 +++++++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_domain.c | 7 ++++ ...ml2argv-net-virtio-rxqueuesize-invalid-size.xml | 29 +++++++++++++++ .../qemuxml2argv-net-virtio-rxqueuesize.xml | 29 +++++++++++++++ tests/qemuxml2argvtest.c | 1 + .../qemuxml2xmlout-net-virtio-rxqueuesize.xml | 41 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 10 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize-invalid-size.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 8c15a73..be19bb9 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4650,7 +4650,7 @@ qemu-kvm -net nic,model=? /dev/null <source network='default'/> <target dev='vnet1'/> <model type='virtio'/> - <b><driver name='vhost' txmode='iothread' ioeventfd='on' event_idx='off' queues='5'> + <b><driver name='vhost' txmode='iothread' ioeventfd='on' event_idx='off' queues='5' rx_queue_size='256'> <host csum='off' gso='off' tso4='off' tso6='off' ecn='off' ufo='off' mrg_rxbuf='off'/> <guest csum='off' tso4='off' tso6='off' ecn='off' ufo='off'/> </driver> @@ -4766,6 +4766,20 @@ qemu-kvm -net nic,model=? /dev/null <span class="since">virtio-net since 1.0.6 (QEMU and KVM only)</span> <span class="since">vhost-user since 1.2.17 (QEMU and KVM only)</span> </dd> + <dt><code>rx_queue_size</code></dt> + <dd> + The optional <code>rx_queue_size</code> attribute controls + the size of virtio ring for each queue as described above. + The default value is hypervisor dependent and may change + across its releases. Moreover, some hypervisors may pose + some restrictions on actual value. For instance, latest
I wonder how long this "latest" will be true. Either say "latest as of yyyy-mm-dd" or QEMU version or just leave the example out.
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 61f6dbb..05a1227 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9517,6 +9519,17 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, if (q > 1) def->driver.virtio.queues = q; } + if (rx_queue_size) { + unsigned int q; + if (virStrToLong_uip(rx_queue_size, NULL, 10, &q) < 0) { + virReportError(VIR_ERR_XML_DETAIL, + _("'rx_queue_size' attribute must be positive number: %s"), + rx_queue_size); + goto error; + } + if (q > 1) + def->driver.virtio.rx_queue_size = q;
Pointless condition, you can assign it unconditionally.
+ } if ((str = virXPathString("string(./driver/host/@csum)", ctxt))) { if ((val = virTristateSwitchTypeFromString(str)) <= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -9697,6 +9710,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, VIR_FREE(ioeventfd); VIR_FREE(event_idx); VIR_FREE(queues); + VIR_FREE(rx_queue_size); VIR_FREE(str); VIR_FREE(filter); VIR_FREE(type); @@ -20890,6 +20904,8 @@ virDomainVirtioNetDriverFormat(char **outstr, } if (def->driver.virtio.queues) virBufferAsprintf(&buf, "queues='%u' ", def->driver.virtio.queues); + if (def->driver.virtio.rx_queue_size) + virBufferAsprintf(&buf, "rx_queue_size='%u' ", def->driver.virtio.rx_queue_size);
Long line.
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c1fb771..29ade0e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2475,6 +2475,13 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, "not supported by QEMU")); goto cleanup; } + + if (STREQ_NULLABLE(net->model, "virtio") && + net->driver.virtio.rx_queue_size & (net->driver.virtio.rx_queue_size - 1)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("rx_queue_size has to be a power of two")); + goto cleanup; + }
No heck for the boundaries that you mentioned in the example? I would expect that boundaries to be checked when they are written there. I understand that it doesn't make sense since we can't know them and adjusting them after every change in qemu is plain wrong. I guess I just wanted to say I was surprised =) ACK with those first three things fixed. Martin

Just like in the previous commit, teach qemu driver to detect whether qemu supports this configuration knob or not. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_capabilities.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2ca7803..c71b4dc 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -342,6 +342,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "smm", "virtio-pci-disable-legacy", "query-hotpluggable-cpus", + + "virtio-net.rx_queue_size", /* 235 */ ); @@ -1584,6 +1586,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = { static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioNet[] = { { "tx", QEMU_CAPS_VIRTIO_TX_ALG }, { "event_idx", QEMU_CAPS_VIRTIO_NET_EVENT_IDX }, + { "rx_queue_size", QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioSCSI[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index a74d39f..26ac1fa 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -376,6 +376,9 @@ typedef enum { QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, /* virtio-*pci.disable-legacy */ QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS, /* qmp command query-hotpluggable-cpus */ + /* 235 */ + QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE, /* virtio-net-*.rx_queue_size */ + QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; -- 2.8.4

Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_command.c | 8 +++++++ .../qemuxml2argv-net-virtio-rxqueuesize.args | 25 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 3 files changed, 35 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 982c33c..fce779b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3553,6 +3553,14 @@ qemuBuildNicDevStr(virDomainDefPtr def, virBufferAsprintf(&buf, ",mq=on,vectors=%zu", 2 * vhostfdSize + 2); } } + if (usingVirtio && net->driver.virtio.rx_queue_size) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio rx_queue_size option is not supported with this QEMU binary")); + goto error; + } + virBufferAsprintf(&buf, ",rx_queue_size=%u", net->driver.virtio.rx_queue_size); + } if (vlan == -1) virBufferAsprintf(&buf, ",netdev=host%s", net->info.alias); else diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.args b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.args new file mode 100644 index 0000000..7d275a7 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.args @@ -0,0 +1,25 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-usb \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ +-device virtio-net-pci,rx_queue_size=512,vlan=0,id=net0,mac=00:11:22:33:44:55,\ +bus=pci.0,addr=0x3 \ +-net user,vlan=0,name=hostnet0 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d0be22d..f9a006d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1043,6 +1043,8 @@ mymain(void) QEMU_CAPS_VIRTIO_S390); DO_TEST("net-virtio-ccw", QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); + DO_TEST("net-virtio-rxqueuesize", + QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE); DO_TEST_PARSE_ERROR("net-virtio-rxqueuesize-invalid-size", NONE); DO_TEST("net-eth", NONE); DO_TEST("net-eth-ifname", NONE); -- 2.8.4

On Wed, Aug 31, 2016 at 05:10:35PM +0200, Michal Privoznik wrote:
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_command.c | 8 +++++++ .../qemuxml2argv-net-virtio-rxqueuesize.args | 25 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 3 files changed, 35 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.args
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 982c33c..fce779b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3553,6 +3553,14 @@ qemuBuildNicDevStr(virDomainDefPtr def, virBufferAsprintf(&buf, ",mq=on,vectors=%zu", 2 * vhostfdSize + 2); } } + if (usingVirtio && net->driver.virtio.rx_queue_size) {
I kinda hate that we blindly go on if it's not virtio device, so that users might thing they increased the ring size but actually we just skip using that tunable at all. But since we do that with, literally, all the other tunables... ACK series (when it is pushed in QEMU, which it looks like it's queued for after the release) Martin
participants (2)
-
Martin Kletzander
-
Michal Privoznik