From nobody Sat Apr 27 23:53:16 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1517493901106617.1701923939115; Thu, 1 Feb 2018 06:05:01 -0800 (PST) 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 B1441C0AA2; Thu, 1 Feb 2018 14:04:58 +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 E648B4FA2B; Thu, 1 Feb 2018 14:04:57 +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 7695518033D9; Thu, 1 Feb 2018 14:04:56 +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 w11E4shW029794 for ; Thu, 1 Feb 2018 09:04:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9880E5D969; Thu, 1 Feb 2018 14:04:54 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92C625D721; Thu, 1 Feb 2018 14:04:46 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 1 Feb 2018 15:04:45 +0100 Message-Id: <742ff144827b72bbf22bf16a7848586726d3bc10.1517493752.git.mprivozn@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] qemu: Expose rx/tx_queue_size in qemu.conf too 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.27]); Thu, 01 Feb 2018 14:04:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In 2074ef6cd4a2 and c56cdf259 (and friends) we've added two attributes to virtio NICs: rx_queue_size and tx_queue_size. However, sysadmins might want to set these on per-host basis but don't necessarily have an access to domain XML (e.g. because they are generated by some other app). So let's expose them under qemu.conf (the settings from domain XML still take precedence as they are more specific ones). Signed-off-by: Michal Privoznik Reviewed-by: John Ferlan --- diff to v1: - Reworded docs and config file comment - Simplified logic in qemuBuildNicDevStr a bit - Make the values require qemu with corresponding capabilities docs/formatdomain.html.in | 14 ++++++++-- src/qemu/libvirtd_qemu.aug | 4 +++ src/qemu/qemu.conf | 6 +++++ src/qemu/qemu_command.c | 55 +++++++++++++++++++++++++++-------= ---- src/qemu/qemu_command.h | 3 ++- src/qemu/qemu_conf.c | 4 +++ src/qemu/qemu_conf.h | 3 +++ src/qemu/qemu_hotplug.c | 2 +- src/qemu/test_libvirtd_qemu.aug.in | 2 ++ 9 files changed, 74 insertions(+), 19 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 3ec1173c6..6707744bd 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5456,7 +5456,12 @@ qemu-kvm -net nic,model=3D? /dev/null some restrictions on actual value. For instance, latest QEMU (as of 2016-09-01) requires value to be a power of two from [256, 1024] range. - Since 2.3.0 (QEMU and KVM only)
<= br/> + Since 2.3.0 (QEMU and KVM only) + Additionally, since 4.1.0 the + value can be set in the qemu.conf file in order + to override the hypervisor default value. Note that XML has + higher precedence because it's more specific. +

=20 In general you should leave this option alone, unless you are very certain you know what you are doing. @@ -5472,7 +5477,12 @@ qemu-kvm -net nic,model=3D? /dev/null range. In addition to that, this may work only for a subset of interface types, e.g. aforementioned QEMU enables this option only for vhostuser type. - Since 3.7.0 (QEMU and KVM only)
<= br/> + Since 3.7.0 (QEMU and KVM only) + Additionally, since 4.1.0 the + value can be set in the qemu.conf file in order + to override the hypervisor default value. Note that XML has + higher precedence because it's more specific. +

=20 In general you should leave this option alone, unless you are very certain you know what you are doing. diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index c19bf3a43..084290296 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -118,6 +118,9 @@ module Libvirtd_qemu =3D let vxhs_entry =3D bool_entry "vxhs_tls" | str_entry "vxhs_tls_x509_cert_dir" =20 + let virtio_entry =3D int_entry "rx_queue_size" + | int_entry "tx_queue_size" + (* Each entry in the config is one of the following ... *) let entry =3D default_tls_entry | vnc_entry @@ -137,6 +140,7 @@ module Libvirtd_qemu =3D | gluster_debug_level_entry | memory_entry | vxhs_entry + | virtio_entry =20 let comment =3D [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \= t\n][^\n]*)?/ . del /\n/ "\n" ] let empty =3D [ label "#empty" . eol ] diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index 43dd561cc..62c4265ea 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -775,3 +775,9 @@ # This directory is used for memoryBacking source if configured as file. # NOTE: big files will be stored here #memory_backing_dir =3D "/var/lib/libvirt/qemu/ram" + +# The following two values set the default RX/TX ring buffer size for virt= io +# interfaces. These values are taken unless overridden in domain XML. For = more +# info consult docs to corresponding attributes from domain XML. +#rx_queue_size =3D 1024 +#tx_queue_size =3D 1024 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 899f0cbbb..543270028 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3751,7 +3751,8 @@ qemuBuildNicStr(virDomainNetDefPtr net, =20 =20 char * -qemuBuildNicDevStr(virDomainDefPtr def, +qemuBuildNicDevStr(virQEMUDriverConfigPtr cfg, + virDomainDefPtr def, virDomainNetDefPtr net, int vlan, unsigned int bootindex, @@ -3871,21 +3872,41 @@ qemuBuildNicDevStr(virDomainDefPtr def, virBufferAsprintf(&buf, ",mq=3Don,vectors=3D%zu", 2 * vhostfdS= ize + 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; + if (usingVirtio) { + unsigned int rx_queue_size =3D net->driver.virtio.rx_queue_size; + + if (rx_queue_size =3D=3D 0) + rx_queue_size =3D cfg->rx_queue_size; + + if (rx_queue_size) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SI= ZE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio rx_queue_size option is " + "not supported with this QEMU binary")); + goto error; + } + + net->driver.virtio.rx_queue_size =3D rx_queue_size; + virBufferAsprintf(&buf, ",rx_queue_size=3D%u", rx_queue_size); } - 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; + if (usingVirtio) { + unsigned int tx_queue_size =3D net->driver.virtio.tx_queue_size; + + if (tx_queue_size =3D=3D 0) + tx_queue_size =3D cfg->tx_queue_size; + + if (tx_queue_size) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SI= ZE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio tx_queue_size option is " + "not supported with this QEMU binary")); + goto error; + } + + net->driver.virtio.tx_queue_size =3D tx_queue_size; + virBufferAsprintf(&buf, ",tx_queue_size=3D%u", tx_queue_size); } - virBufferAsprintf(&buf, ",tx_queue_size=3D%u", net->driver.virtio.= tx_queue_size); } =20 if (usingVirtio && net->mtu) { @@ -8571,7 +8592,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, virCommandAddArg(cmd, netdev); VIR_FREE(netdev); =20 - if (!(nic =3D qemuBuildNicDevStr(def, net, -1, bootindex, + if (!(nic =3D qemuBuildNicDevStr(cfg, def, net, -1, bootindex, queues, qemuCaps))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Error generating NIC -device string")); @@ -8608,6 +8629,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, int **nicindexes, bool chardevStdioLogd) { + virQEMUDriverConfigPtr cfg =3D NULL; int ret =3D -1; char *nic =3D NULL, *host =3D NULL; int *tapfd =3D NULL; @@ -8669,6 +8691,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, return -1; } =20 + cfg =3D virQEMUDriverGetConfig(driver); + switch (actualType) { case VIR_DOMAIN_NET_TYPE_NETWORK: case VIR_DOMAIN_NET_TYPE_BRIDGE: @@ -8864,7 +8888,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, virCommandAddArgList(cmd, "-netdev", host, NULL); } if (qemuDomainSupportsNicdev(def, net)) { - if (!(nic =3D qemuBuildNicDevStr(def, net, vlan, bootindex, + if (!(nic =3D qemuBuildNicDevStr(cfg, def, net, vlan, bootindex, vhostfdSize, qemuCaps))) goto cleanup; virCommandAddArgList(cmd, "-device", nic, NULL); @@ -8908,6 +8932,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, VIR_FREE(host); VIR_FREE(tapfdName); VIR_FREE(vhostfdName); + virObjectUnref(cfg); return ret; } =20 diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 31c9da673..644988329 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -90,7 +90,8 @@ char *qemuBuildNicStr(virDomainNetDefPtr net, int vlan); =20 /* Current, best practice */ -char *qemuBuildNicDevStr(virDomainDefPtr def, +char *qemuBuildNicDevStr(virQEMUDriverConfigPtr cfg, + virDomainDefPtr def, virDomainNetDefPtr net, int vlan, unsigned int bootindex, diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index af503d31c..2fa96431f 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -912,6 +912,10 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr= cfg, if (virConfGetValueString(conf, "memory_backing_dir", &cfg->memoryBack= ingDir) < 0) goto cleanup; =20 + if (virConfGetValueUInt(conf, "rx_queue_size", &cfg->rx_queue_size) < = 0 || + virConfGetValueUInt(conf, "tx_queue_size", &cfg->tx_queue_size) < = 0) + goto cleanup; + ret =3D 0; =20 cleanup: diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index a553e30e2..3f38a76c2 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -206,6 +206,9 @@ struct _virQEMUDriverConfig { =20 bool vxhsTLS; char *vxhsTLSx509certdir; + + unsigned int rx_queue_size; + unsigned int tx_queue_size; }; =20 /* Main driver state */ diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 2aa927e62..0672ed130 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1120,7 +1120,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, for (i =3D 0; i < vhostfdSize; i++) VIR_FORCE_CLOSE(vhostfd[i]); =20 - if (!(nicstr =3D qemuBuildNicDevStr(vm->def, net, vlan, 0, + if (!(nicstr =3D qemuBuildNicDevStr(cfg, vm->def, net, vlan, 0, queueSize, priv->qemuCaps))) goto try_remove; =20 diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qe= mu.aug.in index 688e5b9fd..4fc4e2f4e 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -100,3 +100,5 @@ module Test_libvirtd_qemu =3D { "1" =3D "mount" } } { "memory_backing_dir" =3D "/var/lib/libvirt/qemu/ram" } +{ "rx_queue_size" =3D "1024" } +{ "tx_queue_size" =3D "1024" } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list