From nobody Wed May 1 05:40:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=126.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1625649539302745.529737214254; Wed, 7 Jul 2021 02:18:59 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-22-p4y_GRz9OWetDcok6Qdv-g-1; Wed, 07 Jul 2021 05:18:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6BEB9802934; Wed, 7 Jul 2021 09:18:51 +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 4E6392C00F; Wed, 7 Jul 2021 09:18:51 +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 1A2B51809CB3; Wed, 7 Jul 2021 09:18:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1679Ic2l012730 for ; Wed, 7 Jul 2021 05:18:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 55AFED7B2D; Wed, 7 Jul 2021 09:18:38 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4FA35D7B05 for ; Wed, 7 Jul 2021 09:18:34 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ACCD889C7DC for ; Wed, 7 Jul 2021 09:18:34 +0000 (UTC) Received: from m15113.mail.126.com (m15113.mail.126.com [220.181.15.113]) by relay.mimecast.com with ESMTP id us-mta-555-LI4GVwDzNGOINPptzYdTHQ-1; Wed, 07 Jul 2021 05:18:32 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.27]) by smtp3 (Coremail) with SMTP id DcmowAD3_wtfceVga0SWSw--.5650S3; Wed, 07 Jul 2021 17:18:27 +0800 (CST) X-MC-Unique: p4y_GRz9OWetDcok6Qdv-g-1 X-MC-Unique: LI4GVwDzNGOINPptzYdTHQ-1 From: zhangjl02 To: libvir-list@redhat.com Subject: [PATCHv3 1/4] virDomain: interface: add virDomainNetDefIsOvsport Date: Wed, 7 Jul 2021 17:18:16 +0800 Message-Id: <20210707091819.1861-2-jx8zjs@126.com> In-Reply-To: <20210707091819.1861-1-jx8zjs@126.com> References: <20210707091819.1861-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DcmowAD3_wtfceVga0SWSw--.5650S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr4xCFy8Gw4xKw4kGr17Jrb_yoW8KFWfpa s8JFnrGw48Xrs5Ga4qg3WUZw1qkay8XFZayFyS9w17tF4UXrWDJw1Sqr1xZa1Yvr40vFy7 Cr1SqayDWF12kFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j0MKZUUUUU= X-Originating-IP: [58.56.96.27] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbi5APISFpEBPxfkgAAsM X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: shenjiatong@inspur.com, zhangjl02@inspur.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1625649540676100001 Content-Type: text/plain; charset="utf-8" From: zhangjl02 Tell whether a port definition is an ovs managed virtual port Reviewed-by: Michal Privoznik > Reviewed-by: Michal Privoznik --- diff to v2: - Delete actualType argument, get it in function. - Format code. Thanks to Michal Privoznik's advice. --- src/conf/domain_conf.c | 11 +++++++++++ src/conf/domain_conf.h | 2 ++ src/libvirt_private.syms | 1 + 3 files changed, 14 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 04c10df0a9..5a27cd9d7d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29126,6 +29126,17 @@ virDomainNetGetActualVirtPortProfile(const virDoma= inNetDef *iface) } } =20 +/* Check whether the port is an ovs managed port */ +bool +virDomainNetDefIsOvsport(const virDomainNetDef *net) +{ + const virNetDevVPortProfile *vport =3D virDomainNetGetActualVirtPortPr= ofile(net); + virDomainNetType actualType =3D virDomainNetGetActualType(net); + + return (actualType =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE) && vport && + vport->virtPortType =3D=3D VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH; +} + const virNetDevBandwidth * virDomainNetGetActualBandwidth(const virDomainNetDef *iface) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4d9d499b16..2a36c5acf1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3610,6 +3610,8 @@ int virDomainNetGetActualDirectMode(const virDomainNe= tDef *iface); virDomainHostdevDef *virDomainNetGetActualHostdev(virDomainNetDef *iface); const virNetDevVPortProfile * virDomainNetGetActualVirtPortProfile(const virDomainNetDef *iface); +bool +virDomainNetDefIsOvsport(const virDomainNetDef *net); const virNetDevBandwidth * virDomainNetGetActualBandwidth(const virDomainNetDef *iface); const virNetDevVlan *virDomainNetGetActualVlan(const virDomainNetDef *ifac= e); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 43e6398ae5..110b243e28 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -518,6 +518,7 @@ virDomainNetDefActualFromNetworkPort; virDomainNetDefActualToNetworkPort; virDomainNetDefFormat; virDomainNetDefFree; +virDomainNetDefIsOvsport; virDomainNetDefNew; virDomainNetDefToNetworkPort; virDomainNetDHCPInterfaces; --=20 2.30.2.windows.1 From nobody Wed May 1 05:40:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=126.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1625649529399926.8596829957659; Wed, 7 Jul 2021 02:18:49 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-tlnha9SSNXefrpZF6GYyow-1; Wed, 07 Jul 2021 05:18:46 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5C6B2804302; Wed, 7 Jul 2021 09:18:41 +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 C19545C1D5; Wed, 7 Jul 2021 09:18:40 +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 9041D1809C99; Wed, 7 Jul 2021 09:18:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1679IcYB012719 for ; Wed, 7 Jul 2021 05:18:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id EEED22039D4E; Wed, 7 Jul 2021 09:18:37 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA9DE2039D50 for ; Wed, 7 Jul 2021 09:18:35 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0FFC118A01A9 for ; Wed, 7 Jul 2021 09:18:35 +0000 (UTC) Received: from m15113.mail.126.com (m15113.mail.126.com [220.181.15.113]) by relay.mimecast.com with ESMTP id us-mta-360-VER0cI-UOVKqYQ1li1vbFQ-1; Wed, 07 Jul 2021 05:18:32 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.27]) by smtp3 (Coremail) with SMTP id DcmowAD3_wtfceVga0SWSw--.5650S4; Wed, 07 Jul 2021 17:18:27 +0800 (CST) X-MC-Unique: tlnha9SSNXefrpZF6GYyow-1 X-MC-Unique: VER0cI-UOVKqYQ1li1vbFQ-1 From: zhangjl02 To: libvir-list@redhat.com Subject: [PATCHv3 2/4] virDomain: interface: add virNetDevOpenvswitchInterfaceSetQos and virNetDevOpenvswitchInterfaceClearQos Date: Wed, 7 Jul 2021 17:18:17 +0800 Message-Id: <20210707091819.1861-3-jx8zjs@126.com> In-Reply-To: <20210707091819.1861-1-jx8zjs@126.com> References: <20210707091819.1861-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DcmowAD3_wtfceVga0SWSw--.5650S4 X-Coremail-Antispam: 1Uf129KBjvAXoW3Cw4DGr17GF43Cr13ZrW7XFb_yoW8JF4DJo W3Gr47Kr1DW34Uu3ZYya1xG3yUAr1rKrsxur1Y9a98Jry8GrZYvrykAws8AFsaqFW8Ar17 WFySqrW3GFsrCr1fn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73VFW2AGmfu7bjvjm3 AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjxU49NVUUUUU X-Originating-IP: [58.56.96.27] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbinwPISFpEB30etAAAsS X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: shenjiatong@inspur.com, zhangjl02@inspur.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1625649530261100003 Content-Type: text/plain; charset="utf-8" From: zhangjl02 Introduce qos setting and cleaning method. Use ovs command to set qos parameters on specific interface of qemu virtual machine. When an ovs port is created, we add 'ifname' to external-ids. When setting qos on an ovs port, query its qos and queue. If found, change qos on queried queue and qos, otherwise create new queue and qos. When cleaning qos, query and clean queues and qos in ovs table record by 'ifname' and 'vmid'. Reviewed-by: Michal Privoznik > Reviewed-by: Michal Privoznik --- diff to v2: - format and optimize code structure --- src/libvirt_private.syms | 2 + src/util/virnetdevopenvswitch.c | 274 ++++++++++++++++++++++++++++++++ src/util/virnetdevopenvswitch.h | 11 ++ 3 files changed, 287 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 110b243e28..36322d03b3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2807,8 +2807,10 @@ virNetDevMidonetUnbindPort; virNetDevOpenvswitchAddPort; virNetDevOpenvswitchGetMigrateData; virNetDevOpenvswitchGetVhostuserIfname; +virNetDevOpenvswitchInterfaceClearQos; virNetDevOpenvswitchInterfaceGetMaster; virNetDevOpenvswitchInterfaceParseStats; +virNetDevOpenvswitchInterfaceSetQos; virNetDevOpenvswitchInterfaceStats; virNetDevOpenvswitchMaybeUnescapeReply; virNetDevOpenvswitchRemovePort; diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index eac68d9556..7a64a8dbe6 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -30,6 +30,7 @@ #include "virlog.h" #include "virjson.h" #include "virfile.h" +#include "virutil.h" =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 @@ -140,6 +141,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, con= st char *ifname, g_autofree char *ifaceid_ex_id =3D NULL; g_autofree char *profile_ex_id =3D NULL; g_autofree char *vmid_ex_id =3D NULL; + g_autofree char *ifname_ex_id =3D NULL; =20 virMacAddrFormat(macaddr, macaddrstr); virUUIDFormat(ovsport->interfaceID, ifuuidstr); @@ -149,6 +151,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, con= st char *ifname, macaddrstr); ifaceid_ex_id =3D g_strdup_printf("external-ids:iface-id=3D\"%s\"", if= uuidstr); vmid_ex_id =3D g_strdup_printf("external-ids:vm-id=3D\"%s\"", vmuuidst= r); + ifname_ex_id =3D g_strdup_printf("external-ids:ifname=3D\"%s\"", ifnam= e); if (ovsport->profileID[0] !=3D '\0') { profile_ex_id =3D g_strdup_printf("external-ids:port-profile=3D\"%= s\"", ovsport->profileID); @@ -174,6 +177,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, con= st char *ifname, "--", "set", "Interface", ifname, ifaceid_ex_= id, "--", "set", "Interface", ifname, vmid_ex_id, "--", "set", "Interface", ifname, profile_ex_= id, + "--", "set", "Interface", ifname, ifname_ex_i= d, "--", "set", "Interface", ifname, "external-ids:iface-status=3Dactive", NULL); @@ -614,3 +618,273 @@ int virNetDevOpenvswitchUpdateVlan(const char *ifname, =20 return 0; } + + +/** + * virNetDevOpenvswitchInterfaceSetQos: + * @ifname: on which interface + * @bandwidth: rates to set (may be NULL) + * @swapped: true if IN/OUT should be set contrariwise + * + * Update qos configuration of an OVS port. + * + * If @swapped is set, the IN part of @bandwidth is set on + * @ifname's TX, and vice versa. If it is not set, IN is set on + * RX and OUT on TX. This is because for some types of interfaces + * domain and the host live on the same side of the interface (so + * domain's RX/TX is host's RX/TX), and for some it's swapped + * (domain's RX/TX is hosts's TX/RX). + * + * Return 0 on success, -1 otherwise. + */ +int +virNetDevOpenvswitchInterfaceSetQos(const char *ifname, + const virNetDevBandwidth *bandwidth, + const unsigned char *vmid, + bool swapped) +{ + virNetDevBandwidthRate *rx =3D NULL; /* From domain POV */ + virNetDevBandwidthRate *tx =3D NULL; /* From domain POV */ + + if (!bandwidth) { + /* nothing to be enabled */ + return 0; + } + + if (geteuid() !=3D 0) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("Network bandwidth tuning is not available" + " in session mode")); + return -1; + } + + if (!ifname) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("Unable to set bandwidth for interface because " + "device name is unknown")); + return -1; + } + + if (swapped) { + rx =3D bandwidth->out; + tx =3D bandwidth->in; + } else { + rx =3D bandwidth->in; + tx =3D bandwidth->out; + } + + if (!bandwidth->out && !bandwidth->in) { + if (virNetDevOpenvswitchInterfaceClearQos(ifname, vmid) < 0) { + VIR_WARN("Clean qos for interface %s failed", ifname); + } + return 0; + } + + if (tx && tx->average) { + char vmuuidstr[VIR_UUID_STRING_BUFLEN]; + g_autoptr(virCommand) cmd =3D NULL; + g_autofree char *vmid_ex_id =3D NULL; + g_autofree char *ifname_ex_id =3D NULL; + g_autofree char *average =3D NULL; + g_autofree char *peak =3D NULL; + g_autofree char *burst =3D NULL; + g_autofree char *qos_uuid =3D NULL; + g_autofree char *queue_uuid =3D NULL; + + average =3D g_strdup_printf("%llu", tx->average * 8192); + if (tx->burst) + burst =3D g_strdup_printf("%llu", tx->burst * 8192); + if (tx->peak) + peak =3D g_strdup_printf("%llu", tx->peak * 8192); + + /* find queue */ + cmd =3D virNetDevOpenvswitchCreateCmd(); + virUUIDFormat(vmid, vmuuidstr); + vmid_ex_id =3D g_strdup_printf("external-ids:vm-id=3D\"%s\"", vmuu= idstr); + ifname_ex_id =3D g_strdup_printf("external-ids:ifname=3D\"%s\"", i= fname); + virCommandAddArgList(cmd, "--no-heading", "--columns=3D_uuid", "fi= nd", "queue", + vmid_ex_id, ifname_ex_id, NULL); + virCommandSetOutputBuffer(cmd, &queue_uuid); + if (virCommandRun(cmd, NULL) < 0) { + VIR_WARN("Unable to find queue on port %s", ifname); + } + + /* find qos */ + virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "--no-heading", "--columns=3D_uuid", "fi= nd", "qos", + vmid_ex_id, ifname_ex_id, NULL); + virCommandSetOutputBuffer(cmd, &qos_uuid); + if (virCommandRun(cmd, NULL) < 0) { + VIR_WARN("Unable to find qos on port %s", ifname); + } + + /* create qos and set */ + virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); + if (queue_uuid && *queue_uuid) { + g_auto(GStrv) lines =3D g_strsplit(queue_uuid, "\n", 0); + virCommandAddArgList(cmd, "set", "queue", lines[0], NULL); + } else { + virCommandAddArgList(cmd, "set", "port", ifname, "qos=3D@qos1", + vmid_ex_id, ifname_ex_id, + "--", "--id=3D@qos1", "create", "qos", "t= ype=3Dlinux-htb", NULL); + virCommandAddArgFormat(cmd, "other_config:min-rate=3D%s", aver= age); + if (burst) { + virCommandAddArgFormat(cmd, "other_config:burst=3D%s", bur= st); + } + if (peak) { + virCommandAddArgFormat(cmd, "other_config:max-rate=3D%s", = peak); + } + virCommandAddArgList(cmd, "queues:0=3D@queue0", vmid_ex_id, if= name_ex_id, + "--", "--id=3D@queue0", "create", "queue"= , NULL); + } + virCommandAddArgFormat(cmd, "other_config:min-rate=3D%s", average); + if (burst) { + virCommandAddArgFormat(cmd, "other_config:burst=3D%s", burst); + } + if (peak) { + virCommandAddArgFormat(cmd, "other_config:max-rate=3D%s", peak= ); + } + virCommandAddArgList(cmd, vmid_ex_id, ifname_ex_id, NULL); + if (virCommandRun(cmd, NULL) < 0) { + if (*queue_uuid) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to set queue configuration on por= t %s"), ifname); + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to create and set qos configurati= on on port %s"), ifname); + } + return -1; + } + + if (qos_uuid && *qos_uuid) { + g_auto(GStrv) lines =3D g_strsplit(qos_uuid, "\n", 0); + + virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "set", "qos", lines[0], NULL); + virCommandAddArgFormat(cmd, "other_config:min-rate=3D%s", aver= age); + if (burst) { + virCommandAddArgFormat(cmd, "other_config:burst=3D%s", bur= st); + } + if (peak) { + virCommandAddArgFormat(cmd, "other_config:max-rate=3D%s", = peak); + } + virCommandAddArgList(cmd, vmid_ex_id, ifname_ex_id, NULL); + if (virCommandRun(cmd, NULL) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to set qos configuration on port = %s"), ifname); + return -1; + } + } + } + + if (rx) { + g_autoptr(virCommand) cmd =3D NULL; + + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "set", "Interface", ifname, NULL); + virCommandAddArgFormat(cmd, "ingress_policing_rate=3D%llu", rx->av= erage * 8); + if (rx->burst) + virCommandAddArgFormat(cmd, "ingress_policing_burst=3D%llu", r= x->burst * 8); + + if (virCommandRun(cmd, NULL) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to set vlan configuration on port %s"= ), ifname); + return -1; + } + } + + return 0; +} + +int +virNetDevOpenvswitchInterfaceClearQos(const char *ifname, + const unsigned char *vmid) +{ + char vmuuidstr[VIR_UUID_STRING_BUFLEN]; + g_autoptr(virCommand) cmd =3D NULL; + g_autofree char *vmid_ex_id =3D NULL; + g_autofree char *qos_uuid =3D NULL; + g_autofree char *queue_uuid =3D NULL; + g_autofree char *port_qos =3D NULL; + size_t i; + + /* find qos */ + cmd =3D virNetDevOpenvswitchCreateCmd(); + virUUIDFormat(vmid, vmuuidstr); + vmid_ex_id =3D g_strdup_printf("external-ids:vm-id=3D\"%s\"", vmuuidst= r); + virCommandAddArgList(cmd, "--no-heading", "--columns=3D_uuid", "find",= "qos", vmid_ex_id, NULL); + virCommandSetOutputBuffer(cmd, &qos_uuid); + if (virCommandRun(cmd, NULL) < 0) { + VIR_WARN("Unable to find qos on port %s", ifname); + } + + /* find queue */ + virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); + vmid_ex_id =3D g_strdup_printf("external-ids:vm-id=3D\"%s\"", vmuuidst= r); + virCommandAddArgList(cmd, "--no-heading", "--columns=3D_uuid", "find",= "queue", vmid_ex_id, NULL); + virCommandSetOutputBuffer(cmd, &queue_uuid); + if (virCommandRun(cmd, NULL) < 0) { + VIR_WARN("Unable to find queue on port %s", ifname); + } + + if (qos_uuid && *qos_uuid) { + g_auto(GStrv) lines =3D g_strsplit(qos_uuid, "\n", 0); + + /* destroy qos */ + for (i =3D 0; lines[i] !=3D NULL; i++) { + const char *line =3D lines[i]; + if (!*line) { + continue; + } + virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "--no-heading", "--columns=3D_uuid",= "--if-exists", + "list", "port", ifname, "qos", NULL); + virCommandSetOutputBuffer(cmd, &port_qos); + if (virCommandRun(cmd, NULL) < 0) { + VIR_WARN("Unable to remove port qos on port %s", ifname); + } + if (port_qos && *port_qos) { + virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "remove", "port", ifname, "qos",= line, NULL); + if (virCommandRun(cmd, NULL) < 0) { + VIR_WARN("Unable to remove port qos on port %s", ifnam= e); + } + } + virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "destroy", "qos", line, NULL); + if (virCommandRun(cmd, NULL) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to destroy qos on port %s"), ifna= me); + return -1; + } + } + } + /* destroy queue */ + if (queue_uuid && *queue_uuid) { + g_auto(GStrv) lines =3D g_strsplit(queue_uuid, "\n", 0); + + for (i =3D 0; lines[i] !=3D NULL; i++) { + const char *line =3D lines[i]; + if (!*line) { + continue; + } + virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "destroy", "queue", line, NULL); + if (virCommandRun(cmd, NULL) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to destroy queue on port %s"), if= name); + return -1; + } + } + } + + return 0; +} diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitc= h.h index 7525376855..2dcd1aec6b 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -21,6 +21,7 @@ #pragma once =20 #include "internal.h" +#include "virnetdevbandwidth.h" #include "virnetdevvportprofile.h" #include "virnetdevvlan.h" =20 @@ -69,3 +70,13 @@ int virNetDevOpenvswitchGetVhostuserIfname(const char *p= ath, int virNetDevOpenvswitchUpdateVlan(const char *ifname, const virNetDevVlan *virtVlan) ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; + +int virNetDevOpenvswitchInterfaceSetQos(const char *ifname, + const virNetDevBandwidth *bandwidt= h, + const unsigned char *vmid, + bool swapped) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) G_GNUC_WARN_UNUSED_RESULT; + +int virNetDevOpenvswitchInterfaceClearQos(const char *ifname, + const unsigned char *vmid) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; --=20 2.30.2.windows.1 From nobody Wed May 1 05:40:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=126.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1625649544246993.8763440404321; Wed, 7 Jul 2021 02:19:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-304-o5aJsQK4PnCB5YaQ962Ctg-1; Wed, 07 Jul 2021 05:19:01 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 116641B18BC8; Wed, 7 Jul 2021 09:18:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E76C65C1D5; Wed, 7 Jul 2021 09:18:55 +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 681314EA37; Wed, 7 Jul 2021 09:18:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1679IfDx012760 for ; Wed, 7 Jul 2021 05:18:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9FE8710F26F8; Wed, 7 Jul 2021 09:18:41 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9B50C10F26F2 for ; Wed, 7 Jul 2021 09:18:38 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B9685108BDA5 for ; Wed, 7 Jul 2021 09:18:38 +0000 (UTC) Received: from m15113.mail.126.com (m15113.mail.126.com [220.181.15.113]) by relay.mimecast.com with ESMTP id us-mta-559-eyH-WQfKPn-tAKkruBB0NQ-1; Wed, 07 Jul 2021 05:18:36 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.27]) by smtp3 (Coremail) with SMTP id DcmowAD3_wtfceVga0SWSw--.5650S5; Wed, 07 Jul 2021 17:18:27 +0800 (CST) X-MC-Unique: o5aJsQK4PnCB5YaQ962Ctg-1 X-MC-Unique: eyH-WQfKPn-tAKkruBB0NQ-1 From: zhangjl02 To: libvir-list@redhat.com Subject: [PATCHv3 3/4] qemu: interface: remove setting noqueue for ovs port Date: Wed, 7 Jul 2021 17:18:18 +0800 Message-Id: <20210707091819.1861-4-jx8zjs@126.com> In-Reply-To: <20210707091819.1861-1-jx8zjs@126.com> References: <20210707091819.1861-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DcmowAD3_wtfceVga0SWSw--.5650S5 X-Coremail-Antispam: 1Uf129KBjvdXoWrZF45GF18Xry3CF1UJrW7CFg_yoWfZrg_Aa y8Zw4jgF4kGF43ArW7Zay3XryIkrs8Ja1kWa4vq3ZrJF4rCw4rJFsxZws3Zw1Uua47WFWx XFs7W343A3srCjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUnZNVJUUUUU== X-Originating-IP: [58.56.96.27] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbiFwPISFpEBrHrvwAAsp X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: shenjiatong@inspur.com, zhangjl02@inspur.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1625649544888100001 Content-Type: text/plain; charset="utf-8" From: zhangjl02 Return 0 directly if the port is ovs managed. When the ovs port is set noqueue, qos config on this port will not work. Reviewed-by: Michal Privoznik > Reviewed-by: Michal Privoznik --- diff to v2: - remove "actualType" argument --- src/qemu/qemu_domain.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8488f58e09..bb529cc987 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11527,7 +11527,8 @@ qemuDomainInterfaceSetDefaultQDisc(virQEMUDriver *d= river, actualType =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK || actualType =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || actualType =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT) { - if (virNetDevBandwidthSetRootQDisc(net->ifname, "noqueue") < 0) + if (!virDomainNetDefIsOvsport(net) && + virNetDevBandwidthSetRootQDisc(net->ifname, "noqueue") < 0) return -1; } =20 --=20 2.30.2.windows.1 From nobody Wed May 1 05:40:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=126.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1625649540809307.09020440289714; Wed, 7 Jul 2021 02:19:00 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-47-fJmTPQogNMOJjwqCHzrb3Q-1; Wed, 07 Jul 2021 05:18:58 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 716E2362FD; Wed, 7 Jul 2021 09:18:51 +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 51B9A5C1D5; Wed, 7 Jul 2021 09:18:51 +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 1FE971809CB4; Wed, 7 Jul 2021 09:18:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1679IcPH012729 for ; Wed, 7 Jul 2021 05:18:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 55AA8D74DF; Wed, 7 Jul 2021 09:18:38 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F673D7B08 for ; Wed, 7 Jul 2021 09:18:37 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E42D2108BDA1 for ; Wed, 7 Jul 2021 09:18:36 +0000 (UTC) Received: from m15113.mail.126.com (m15113.mail.126.com [220.181.15.113]) by relay.mimecast.com with ESMTP id us-mta-456-txWMkbz_NCeBGDd38Q3z8g-1; Wed, 07 Jul 2021 05:18:34 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.27]) by smtp3 (Coremail) with SMTP id DcmowAD3_wtfceVga0SWSw--.5650S6; Wed, 07 Jul 2021 17:18:28 +0800 (CST) X-MC-Unique: fJmTPQogNMOJjwqCHzrb3Q-1 X-MC-Unique: txWMkbz_NCeBGDd38Q3z8g-1 From: zhangjl02 To: libvir-list@redhat.com Subject: [PATCHv3 4/4] qemu: interface: check and use ovs command to set qos of ovs managed port Date: Wed, 7 Jul 2021 17:18:19 +0800 Message-Id: <20210707091819.1861-5-jx8zjs@126.com> In-Reply-To: <20210707091819.1861-1-jx8zjs@126.com> References: <20210707091819.1861-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DcmowAD3_wtfceVga0SWSw--.5650S6 X-Coremail-Antispam: 1Uf129KBjvJXoW3ArWUGFy8GF1fZrW3trWxtFb_yoWxuF47p3 W8GF95Kr4rXF4xJF43ua18uFy3J3W09rZ5CFy7X340vw1UJry5Xr1fKw10vw1Yvrs3Za4r C3WUZa1DW3Wqk3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jq385UUUUU= X-Originating-IP: [58.56.96.27] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbiFwPISFpEBrHrvwABso X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: shenjiatong@inspur.com, zhangjl02@inspur.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1625649542678100003 Content-Type: text/plain; charset="utf-8" From: zhangjl02 When qos is set or delete, we have to check if the port is an ovs managed port. If true, call the virNetDevOpenvswitchInterfaceSetQos function when q= os is set, and call the virNetDevOpenvswitchInterfaceClearQos function when the interface is to be destroyed. Reviewed-by: Michal Privoznik > Reviewed-by: Michal Privoznik --- diff to v2: - remove "acutualType" argument - optimize code structure Thank to Michal Privoznik for helping solve these problems. --- src/qemu/qemu_command.c | 10 ++++++++-- src/qemu/qemu_driver.c | 23 +++++++++++++++++++++-- src/qemu/qemu_hotplug.c | 35 ++++++++++++++++++++++++++--------- src/qemu/qemu_process.c | 7 ++++++- 4 files changed, 61 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ea513693f7..522394bb74 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8610,9 +8610,15 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, actualBandwidth =3D virDomainNetGetActualBandwidth(net); if (actualBandwidth) { if (virNetDevSupportsBandwidth(actualType)) { - if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false, - !virDomainNetTypeSharesHostView(net)= ) < 0) + if (virDomainNetDefIsOvsport(net)) { + if (virNetDevOpenvswitchInterfaceSetQos(net->ifname, actua= lBandwidth, + def->uuid, + !virDomainNetTypeS= haresHostView(net)) < 0) + goto cleanup; + } else if (virNetDevBandwidthSet(net->ifname, actualBandwidth,= false, + !virDomainNetTypeSharesHostVi= ew(net)) < 0) { goto cleanup; + } } else { VIR_WARN("setting bandwidth on interfaces of " "type '%s' is not implemented yet", diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 235f575901..72f550bf8d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10231,6 +10231,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, bool inboundSpecified =3D false, outboundSpecified =3D false; int actualType; bool qosSupported =3D true; + bool ovsType =3D false; =20 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); @@ -10277,6 +10278,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, if (net) { actualType =3D virDomainNetGetActualType(net); qosSupported =3D virNetDevSupportsBandwidth(actualType); + ovsType =3D virDomainNetDefIsOvsport(net); } =20 if (qosSupported && persistentNet) { @@ -10366,8 +10368,25 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, } } =20 - if (virNetDevBandwidthSet(net->ifname, newBandwidth, false, - !virDomainNetTypeSharesHostView(net)) < = 0) { + if (ovsType) { + if (virNetDevOpenvswitchInterfaceSetQos(net->ifname, newBandwi= dth, + vm->def->uuid, + !virDomainNetTypeShare= sHostView(net)) < 0) { + virErrorPtr orig_err; + + virErrorPreserveLast(&orig_err); + ignore_value(virNetDevOpenvswitchInterfaceSetQos(net->ifna= me, newBandwidth, + vm->def->= uuid, + !virDomai= nNetTypeSharesHostView(net))); + if (net->bandwidth) { + ignore_value(virDomainNetBandwidthUpdate(net, + net->bandwidt= h)); + } + virErrorRestore(&orig_err); + goto endjob; + } + } else if (virNetDevBandwidthSet(net->ifname, newBandwidth, false, + !virDomainNetTypeSharesHostView(n= et)) < 0) { virErrorPtr orig_err; =20 virErrorPreserveLast(&orig_err); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d2a354d026..cb6a4e4ea5 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1409,9 +1409,15 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, actualBandwidth =3D virDomainNetGetActualBandwidth(net); if (actualBandwidth) { if (virNetDevSupportsBandwidth(actualType)) { - if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false, - !virDomainNetTypeSharesHostView(net)= ) < 0) + if (virDomainNetDefIsOvsport(net)) { + if (virNetDevOpenvswitchInterfaceSetQos(net->ifname, actua= lBandwidth, + vm->def->uuid, + !virDomainNetTypeS= haresHostView(net)) < 0) + goto cleanup; + } else if (virNetDevBandwidthSet(net->ifname, actualBandwidth,= false, + !virDomainNetTypeSharesHostVi= ew(net)) < 0) { goto cleanup; + } } else { VIR_WARN("setting bandwidth on interfaces of " "type '%s' is not implemented yet", @@ -3914,9 +3920,15 @@ qemuDomainChangeNet(virQEMUDriver *driver, const virNetDevBandwidth *newb =3D virDomainNetGetActualBandwidth(= newdev); =20 if (newb) { - if (virNetDevBandwidthSet(newdev->ifname, newb, false, - !virDomainNetTypeSharesHostView(newd= ev)) < 0) + if (virDomainNetDefIsOvsport(newdev)) { + if (virNetDevOpenvswitchInterfaceSetQos(newdev->ifname, ne= wb, + vm->def->uuid, + !virDomainNetTypeS= haresHostView(newdev)) < 0) + goto cleanup; + } else if (virNetDevBandwidthSet(newdev->ifname, newb, false, + !virDomainNetTypeSharesHostVi= ew(newdev)) < 0) { goto cleanup; + } } else { /* * virNetDevBandwidthSet() doesn't clear any existing @@ -4665,11 +4677,16 @@ qemuDomainRemoveNetDevice(virQEMUDriver *driver, if (!(charDevAlias =3D qemuAliasChardevFromDevAlias(net->info.alias))) return -1; =20 - if (virDomainNetGetActualBandwidth(net) && - virNetDevSupportsBandwidth(virDomainNetGetActualType(net)) && - virNetDevBandwidthClear(net->ifname) < 0) - VIR_WARN("cannot clear bandwidth setting for device : %s", - net->ifname); + if (virNetDevSupportsBandwidth(virDomainNetGetActualType(net))) { + if (virDomainNetDefIsOvsport(net)) { + if (virNetDevOpenvswitchInterfaceClearQos(net->ifname, vm->def= ->uuid) < 0) + VIR_WARN("cannot clear bandwidth setting for ovs device : = %s", + net->ifname); + } else if (virNetDevBandwidthClear(net->ifname) < 0) { + VIR_WARN("cannot clear bandwidth setting for device : %s", + net->ifname); + } + } =20 /* deactivate the tap/macvtap device on the host, which could also * affect the parent device (e.g. macvtap passthrough mode sets diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2b03b0ab98..3693796b06 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7966,7 +7966,6 @@ void qemuProcessStop(virQEMUDriver *driver, for (i =3D 0; i < def->nnets; i++) { virDomainNetDef *net =3D def->nets[i]; vport =3D virDomainNetGetActualVirtPortProfile(net); - switch (virDomainNetGetActualType(net)) { case VIR_DOMAIN_NET_TYPE_DIRECT: ignore_value(virNetDevMacVLanDeleteWithVPortProfile( @@ -8023,6 +8022,12 @@ void qemuProcessStop(virQEMUDriver *driver, else VIR_WARN("Unable to release network device '%s'", NULLSTR(= net->ifname)); } + + if (virDomainNetDefIsOvsport(net) && + virNetDevOpenvswitchInterfaceClearQos(net->ifname, vm->def->uu= id) < 0) { + VIR_WARN("cannot clear bandwidth setting for ovs device : %s", + net->ifname); + } } =20 retry: --=20 2.30.2.windows.1