From nobody Sun Apr 28 21:11:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501670896051862.7893504462917; Wed, 2 Aug 2017 03:48:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83DE181226; Wed, 2 Aug 2017 10:48:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B6EE7813E; Wed, 2 Aug 2017 10:48:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9CC641803B21; Wed, 2 Aug 2017 10:48:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v72Aif6I010469 for ; Wed, 2 Aug 2017 06:44:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id BD1B0675BD; Wed, 2 Aug 2017 10:44:41 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EBA26941D for ; Wed, 2 Aug 2017 10:44:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 83DE181226 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 2 Aug 2017 12:44:37 +0200 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3] Add support for virtio-net.tx_queue_size X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 02 Aug 2017 10:48:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1462653 Just like I've added support for setting rx_queue_size (in c56cdf259 and friends), qemu just gained support for setting tx ring size. Signed-off-by: Michal Privoznik --- diff to v2: - rebase to current HEAD There's no fundamental change since v1. It's just discussion on this patch = that makes me send newer versions because the older ones do not apply cleanly anymore. 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 | 4 +++- src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 8 ++++++++ src/qemu/qemu_domain.c | 16 +++++++++++-= ---- ...e.args =3D> qemuxml2argv-net-virtio-rxtxqueuesize.args} | 4 ++-- ...ize.xml =3D> qemuxml2argv-net-virtio-rxtxqueuesize.xml} | 2 +- tests/qemuxml2argvtest.c | 5 +++-- ...e.xml =3D> qemuxml2xmlout-net-virtio-rxtxqueuesize.xml} | 2 +- tests/qemuxml2xmltest.c | 2 +- 13 files changed, 68 insertions(+), 14 deletions(-) rename tests/qemuxml2argvdata/{qemuxml2argv-net-virtio-rxqueuesize.args = =3D> qemuxml2argv-net-virtio-rxtxqueuesize.args} (85%) rename tests/qemuxml2argvdata/{qemuxml2argv-net-virtio-rxqueuesize.xml =3D= > qemuxml2argv-net-virtio-rxtxqueuesize.xml} (93%) rename tests/qemuxml2xmloutdata/{qemuxml2xmlout-net-virtio-rxqueuesize.xml= =3D> qemuxml2xmlout-net-virtio-rxtxqueuesize.xml} (96%) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 91195be0b..47e21c10d 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5074,7 +5074,7 @@ qemu-kvm -net nic,model=3D? /dev/null <source network=3D'default'/> <target dev=3D'vnet1'/> <model type=3D'virtio'/> - <driver name=3D'vhost' txmode=3D'iothread' ioeventfd=3D'on' even= t_idx=3D'off' queues=3D'5' rx_queue_size=3D'256'> + <driver name=3D'vhost' txmode=3D'iothread' ioeventfd=3D'on' even= t_idx=3D'off' queues=3D'5' rx_queue_size=3D'256' tx_queue_size=3D'256'> <host csum=3D'off' gso=3D'off' tso4=3D'off' tso6=3D'off' ecn=3D'o= ff' ufo=3D'off' mrg_rxbuf=3D'off'/> <guest csum=3D'off' tso4=3D'off' tso6=3D'off' ecn=3D'off' ufo=3D'= off'/> </driver> @@ -5204,6 +5204,20 @@ qemu-kvm -net nic,model=3D? /dev/null In general you should leave this option alone, unless you are very certain you know what you are doing. +
tx_queue_size
+
+ The optional tx_queue_size 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 (as of 2017-07-13) requires value to be a power of two + from [256, 1024] range. + Since 3.6.0 (QEMU and KVM only)
<= br/> + + In general you should leave this option alone, unless you + are very certain you know what you are doing. +
virtio options
For virtio interfaces, diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index a49ce9303..3f56d8f45 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2711,6 +2711,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 34c8f45ed..c3a167576 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9833,6 +9833,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, char *event_idx =3D NULL; char *queues =3D NULL; char *rx_queue_size =3D NULL; + char *tx_queue_size =3D NULL; char *str =3D NULL; char *filter =3D NULL; char *internal =3D NULL; @@ -10006,6 +10007,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, event_idx =3D virXMLPropString(cur, "event_idx"); queues =3D virXMLPropString(cur, "queues"); rx_queue_size =3D virXMLPropString(cur, "rx_queue_size"); + tx_queue_size =3D virXMLPropString(cur, "tx_queue_size"); } else if (xmlStrEqual(cur->name, BAD_CAST "filterref")) { if (filter) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -10403,6 +10405,16 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlo= pt, } def->driver.virtio.rx_queue_size =3D q; } + if (tx_queue_size) { + unsigned int q; + if (virStrToLong_uip(tx_queue_size, NULL, 10, &q) < 0) { + virReportError(VIR_ERR_XML_DETAIL, + _("'tx_queue_size' attribute must be positi= ve number: %s"), + tx_queue_size); + goto error; + } + def->driver.virtio.tx_queue_size =3D q; + } if ((str =3D virXPathString("string(./driver/host/@csum)", ctxt)))= { if ((val =3D virTristateSwitchTypeFromString(str)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -10600,6 +10612,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, VIR_FREE(event_idx); VIR_FREE(queues); VIR_FREE(rx_queue_size); + VIR_FREE(tx_queue_size); VIR_FREE(str); VIR_FREE(filter); VIR_FREE(type); @@ -22497,6 +22510,9 @@ virDomainVirtioNetDriverFormat(char **outstr, if (def->driver.virtio.rx_queue_size) virBufferAsprintf(&buf, " rx_queue_size=3D'%u'", def->driver.virtio.rx_queue_size); + if (def->driver.virtio.tx_queue_size) + virBufferAsprintf(&buf, " tx_queue_size=3D'%u'", + def->driver.virtio.tx_queue_size); =20 virDomainVirtioOptionsFormat(&buf, def->virtio); =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 239b21813..f857f509e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -969,6 +969,7 @@ struct _virDomainNetDef { virTristateSwitch event_idx; unsigned int queues; /* Multiqueue virtio-net */ unsigned int rx_queue_size; + unsigned int tx_queue_size; struct { virTristateSwitch csum; virTristateSwitch gso; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index afe70d00d..e61d2f7b0 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -435,7 +435,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, =20 /* 265 */ "spapr-pci-host-bridge.numa_node", - "vnc-multi-servers" + "vnc-multi-servers", + "virtio-net.tx_queue_size", ); =20 =20 @@ -1705,6 +1706,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjec= tPropsVirtioNet[] =3D { { "tx", QEMU_CAPS_VIRTIO_TX_ALG }, { "event_idx", QEMU_CAPS_VIRTIO_NET_EVENT_IDX }, { "rx_queue_size", QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE }, + { "tx_queue_size", QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE }, { "host_mtu", QEMU_CAPS_VIRTIO_NET_HOST_MTU }, }; =20 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 8b856e1b2..8804cc781 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -422,6 +422,7 @@ typedef enum { /* 265 */ QEMU_CAPS_SPAPR_PCI_HOST_BRIDGE_NUMA_NODE, /* spapr-pci-host-bridge.nu= ma_node=3D */ QEMU_CAPS_VNC_MULTI_SERVERS, /* -vnc vnc=3Dunix:/path */ + QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE, /* virtio-net-*.tx_queue_size */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d1f5c3642..da6ddff6c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3725,6 +3725,14 @@ qemuBuildNicDevStr(virDomainDefPtr def, } virBufferAsprintf(&buf, ",rx_queue_size=3D%u", net->driver.virtio.= rx_queue_size); } + if (usingVirtio && net->driver.virtio.tx_queue_size) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE))= { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio tx_queue_size option is not supported= with this QEMU binary")); + goto error; + } + virBufferAsprintf(&buf, ",tx_queue_size=3D%u", net->driver.virtio.= tx_queue_size); + } =20 if (usingVirtio && net->mtu) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_HOST_MTU)) { diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6fe9aa855..fe27e1122 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3226,11 +3226,17 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDe= f *dev, goto cleanup; } =20 - if (STREQ_NULLABLE(net->model, "virtio") && - net->driver.virtio.rx_queue_size & (net->driver.virtio.rx_queu= e_size - 1)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("rx_queue_size has to be a power of two")); - goto cleanup; + if (STREQ_NULLABLE(net->model, "virtio")) { + if (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; + } + if (net->driver.virtio.tx_queue_size & (net->driver.virtio.tx_= queue_size - 1)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("tx_queue_size has to be a power of two")= ); + goto cleanup; + } } =20 if (net->mtu && diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.arg= s b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxtxqueuesize.args similarity index 85% rename from tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.args rename to tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxtxqueuesize.args index 07c358a02..c78da3d17 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxtxqueuesize.args @@ -21,7 +21,7 @@ server,nowait \ -usb \ -drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ -device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ --device virtio-net-pci,rx_queue_size=3D512,vlan=3D0,id=3Dnet0,mac=3D00:11:= 22:33:44:55,\ -bus=3Dpci.0,addr=3D0x3 \ +-device virtio-net-pci,rx_queue_size=3D512,tx_queue_size=3D1024,vlan=3D0,i= d=3Dnet0,\ +mac=3D00:11:22:33:44:55,bus=3Dpci.0,addr=3D0x3 \ -net user,vlan=3D0,name=3Dhostnet0 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml= b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxtxqueuesize.xml similarity index 93% rename from tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml rename to tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxtxqueuesize.xml index d64e31df2..b51931d52 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxtxqueuesize.xml @@ -22,7 +22,7 @@ - + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index c2c1767c7..aa83013a2 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1167,8 +1167,9 @@ 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("net-virtio-rxtxqueuesize", + QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE, + QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE); DO_TEST_PARSE_ERROR("net-virtio-rxqueuesize-invalid-size", NONE); DO_TEST("net-eth", NONE); DO_TEST("net-eth-ifname", NONE); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize= .xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxtxqueuesize.xml similarity index 96% rename from tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize.= xml rename to tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxtxqueuesize.= xml index 78433026c..5c33a58ad 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxtxqueuesize.xml @@ -29,7 +29,7 @@ - +
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 5b47b0711..bf4d507f6 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -537,7 +537,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-virtio-rxtxqueuesize", NONE); DO_TEST("net-hostdev", NONE); DO_TEST("net-hostdev-vfio", NONE); DO_TEST("net-midonet", NONE); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list