[libvirt] [PATCH v2 1/3] conf: Add support for virtio-net.rx_queue_size
Martin Kletzander
mkletzan at redhat.com
Thu Sep 1 05:45:30 UTC 2016
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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160901/32ff779e/attachment-0001.sig>
More information about the libvir-list
mailing list