From nobody Sun Apr 28 20:50:45 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 1499932452749906.5177344490365; Thu, 13 Jul 2017 00:54:12 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 055EA7CE0E; Thu, 13 Jul 2017 07:54:11 +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 0ED3D60603; Thu, 13 Jul 2017 07:54:10 +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 183D61803B26; Thu, 13 Jul 2017 07:54:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6D7s6hJ029461 for ; Thu, 13 Jul 2017 03:54:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id B823F5DC1A; Thu, 13 Jul 2017 07:54:06 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19F2861B9C for ; Thu, 13 Jul 2017 07:54:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 055EA7CE0E Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 055EA7CE0E From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 13 Jul 2017 09:53:59 +0200 Message-Id: <19335bc48bcfb476d72ccd1bd9a71a728b575311.1499932439.git.mprivozn@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 13 Jul 2017 07:54:11 +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=3D1460323 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 --- 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 | 2 ++ 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, 67 insertions(+), 13 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 7f4bc1d21..d37c89eff 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5065,7 +5065,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> @@ -5195,6 +5195,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 77136108a..7e133a8c1 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2702,6 +2702,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 570cc5c93..7cf638da4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9863,6 +9863,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; @@ -10036,6 +10037,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", @@ -10433,6 +10435,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, @@ -10630,6 +10642,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 1baf85453..1cb8b802c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -967,6 +967,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 db9f9b8b1..f502dd464 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -430,6 +430,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "virtio.iommu_platform", "virtio.ats", "loadparm", + "virtio-net.tx_queue_size", ); =20 =20 @@ -1695,6 +1696,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 fb22815e9..63e792a19 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -416,6 +416,7 @@ typedef enum { QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM, /* virtio-*-pci.iommu_platform */ QEMU_CAPS_VIRTIO_PCI_ATS, /* virtio-*-pci.ats */ QEMU_CAPS_LOADPARM, /* -machine loadparm */ + 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 e290abff6..43fba3b0a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3790,6 +3790,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 ae260de00..b17727811 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3169,11 +3169,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 302c9c892..8ad2ca71b 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1146,8 +1146,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 79347671f..578b07a95 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -523,7 +523,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