From nobody Sun May 19 10:01:20 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 1625129058233995.0297362222798; Thu, 1 Jul 2021 01:44:18 -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-226-k4Q6Vlk2MHeaKfJx6mKDOg-1; Thu, 01 Jul 2021 04:44:15 -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 6EED61084F57; Thu, 1 Jul 2021 08:44:10 +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 49FD95C230; Thu, 1 Jul 2021 08:44: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 17CF01809C9A; Thu, 1 Jul 2021 08:44:10 +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 1618gmxl006249 for ; Thu, 1 Jul 2021 04:42:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 26EDC10D14E4; Thu, 1 Jul 2021 08:42:48 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2304810D14C7 for ; Thu, 1 Jul 2021 08:42:45 +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 86AFC800B28 for ; Thu, 1 Jul 2021 08:42:45 +0000 (UTC) Received: from m15112.mail.126.com (m15112.mail.126.com [220.181.15.112]) by relay.mimecast.com with ESMTP id us-mta-442-NoP7_0XaMyGSnr-QdtW9xg-1; Thu, 01 Jul 2021 04:42:42 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.28]) by smtp2 (Coremail) with SMTP id DMmowAB3LRr6f91ggnb6Cg--.12121S3; Thu, 01 Jul 2021 16:42:38 +0800 (CST) X-MC-Unique: k4Q6Vlk2MHeaKfJx6mKDOg-1 X-MC-Unique: NoP7_0XaMyGSnr-QdtW9xg-1 From: zhangjl02 To: libvir-list@redhat.com Subject: [PATCHv2 1/4] virDomain: interface: add virDomainNetDefIsOvsport Date: Thu, 1 Jul 2021 16:42:03 +0800 Message-Id: <20210701084206.621-2-jx8zjs@126.com> In-Reply-To: <20210701084206.621-1-jx8zjs@126.com> References: <20210701084206.621-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DMmowAB3LRr6f91ggnb6Cg--.12121S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kw1rWw1rXFyrXFykuFWfKrg_yoW8trW5pa sxJFn7Ww48XFs5Ga4qg3WUuw1qk3y8XFWSvFySgw17tF45XrWDJr1aqrn7Za1YyrsF9Fy7 Ar1FqayDWF12kFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jHg4fUUUUU= X-Originating-IP: [58.56.96.28] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbiIR7CSFpEBzbjrwABsX 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 Content-Type: text/plain; charset="utf-8" From: zhangjl02 Tell whether a port definition is an ovs managed virtual port --- src/conf/domain_conf.c | 8 ++++++++ src/conf/domain_conf.h | 2 ++ src/libvirt_private.syms | 1 + 3 files changed, 11 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d78f846a52..7fe72fb3f2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29126,6 +29126,14 @@ virDomainNetGetActualVirtPortProfile(const virDoma= inNetDef *iface) } } =20 +/* Check whether the port is an ovs managed port */ +bool +virDomainNetDefIsOvsport(virDomainNetDef *net, int actualType) { + const virNetDevVPortProfile *vport =3D virDomainNetGetActualVirtPortPr= ofile(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 f706c498ff..a024e4394f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3608,6 +3608,8 @@ int virDomainNetGetActualDirectMode(const virDomainNe= tDef *iface); virDomainHostdevDef *virDomainNetGetActualHostdev(virDomainNetDef *iface); const virNetDevVPortProfile * virDomainNetGetActualVirtPortProfile(const virDomainNetDef *iface); +bool +virDomainNetDefIsOvsport(virDomainNetDef *net, int actualType); 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 68e4b6aab8..2bcbce7288 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -517,6 +517,7 @@ virDomainNetDefActualFromNetworkPort; virDomainNetDefActualToNetworkPort; virDomainNetDefFormat; virDomainNetDefFree; +virDomainNetDefIsOvsport; virDomainNetDefNew; virDomainNetDefToNetworkPort; virDomainNetDHCPInterfaces; --=20 2.30.2.windows.1 From nobody Sun May 19 10:01:20 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 1625128980895631.3370581458572; Thu, 1 Jul 2021 01:43: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-149-Iu6NJQvcP9-dU4YDj5p2hQ-1; Thu, 01 Jul 2021 04:42: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 83F84343CE; Thu, 1 Jul 2021 08:42:52 +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 595325C25D; Thu, 1 Jul 2021 08:42:52 +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 95E581809C9A; Thu, 1 Jul 2021 08:42:50 +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 1618gnJa006266 for ; Thu, 1 Jul 2021 04:42:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id B5589FED2A; Thu, 1 Jul 2021 08:42:49 +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 AFF2E1032BB for ; Thu, 1 Jul 2021 08:42:47 +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 5FA9818A01A0 for ; Thu, 1 Jul 2021 08:42:47 +0000 (UTC) Received: from m15112.mail.126.com (m15112.mail.126.com [220.181.15.112]) by relay.mimecast.com with ESMTP id us-mta-458-zxE1x5IfPRe5TAiqs0sHTQ-1; Thu, 01 Jul 2021 04:42:43 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.28]) by smtp2 (Coremail) with SMTP id DMmowAB3LRr6f91ggnb6Cg--.12121S4; Thu, 01 Jul 2021 16:42:38 +0800 (CST) X-MC-Unique: Iu6NJQvcP9-dU4YDj5p2hQ-1 X-MC-Unique: zxE1x5IfPRe5TAiqs0sHTQ-1 From: zhangjl02 To: libvir-list@redhat.com Subject: [PATCHv2 2/4] virDomain: interface: add virNetDevOpenvswitchInterfaceSetQos and virNetDevOpenvswitchInterfaceClearQos Date: Thu, 1 Jul 2021 16:42:04 +0800 Message-Id: <20210701084206.621-3-jx8zjs@126.com> In-Reply-To: <20210701084206.621-1-jx8zjs@126.com> References: <20210701084206.621-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DMmowAB3LRr6f91ggnb6Cg--.12121S4 X-Coremail-Antispam: 1Uf129KBjvAXoW3Zr1UGrWDZw4xtw43AF1UWrg_yoW8JFy7Ko W3Gr47Kr1kG34Uu3Z0ya17G3yUAr1rKrsxur1Y9a98Jry8GrZYv34kAan8AFsaqFW8Ar17 WFySqrW3GFsrCryfn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73VFW2AGmfu7bjvjm3 AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjxUSUDGUUUUU X-Originating-IP: [58.56.96.28] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbi2R7CSFpEB2ML7wABsS 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 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'. --- src/libvirt_private.syms | 2 + src/util/virnetdevopenvswitch.c | 271 ++++++++++++++++++++++++++++++++ src/util/virnetdevopenvswitch.h | 11 ++ 3 files changed, 284 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2bcbce7288..e60bfa62c5 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2806,8 +2806,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..83acc869cd 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,270 @@ 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 *bandwidt= h, + const unsigned char *vmid, + bool swapped) +{ + char vmuuidstr[VIR_UUID_STRING_BUFLEN]; + virNetDevBandwidthRate *rx =3D NULL; /* From domain POV */ + virNetDevBandwidthRate *tx =3D NULL; /* From domain POV */ + 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; + g_autofree char **lines =3D NULL; + + 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); + } + } + if (tx && tx->average) { + 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) { + 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); + return -1; + } + 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){ + virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); + lines =3D g_strsplit(qos_uuid, "\n", 0); + 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) { + average =3D g_strdup_printf("%llu", rx->average * 8); + if (rx->burst) + burst =3D g_strdup_printf("%llu", rx->burst * 8); + virCommandFree(cmd); + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "set", "Interface", ifname, NULL); + virCommandAddArgFormat(cmd, "ingress_policing_rate=3D%s", average); + if (burst) + virCommandAddArgFormat(cmd, "ingress_policing_burst=3D%s", bur= st); + + if (virCommandRun(cmd, NULL) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to set vlan configuration on port %s"= ), ifname); + return -1; + } + virCommandFree(cmd); + } + + 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; + g_autofree char **lines =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) { + 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) { + 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; +} \ No newline at end of file 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 Sun May 19 10:01:20 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 1625128988098154.31864227635936; Thu, 1 Jul 2021 01:43:08 -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-527-oZS-d-3pOQS6phyOHH71fQ-1; Thu, 01 Jul 2021 04:43:05 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BB7BC69C; Thu, 1 Jul 2021 08:42:59 +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 93B885D6AD; Thu, 1 Jul 2021 08:42:59 +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 2C60A1809CB4; Thu, 1 Jul 2021 08:42:59 +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 1618gmrO006250 for ; Thu, 1 Jul 2021 04:42:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6EEA82087A24; Thu, 1 Jul 2021 08:42:48 +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 697312087A30 for ; Thu, 1 Jul 2021 08:42:45 +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 F049F185A794 for ; Thu, 1 Jul 2021 08:42:44 +0000 (UTC) Received: from m15112.mail.126.com (m15112.mail.126.com [220.181.15.112]) by relay.mimecast.com with ESMTP id us-mta-173-84yGNyjENB-jJNOPGjGggw-1; Thu, 01 Jul 2021 04:42:42 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.28]) by smtp2 (Coremail) with SMTP id DMmowAB3LRr6f91ggnb6Cg--.12121S5; Thu, 01 Jul 2021 16:42:39 +0800 (CST) X-MC-Unique: oZS-d-3pOQS6phyOHH71fQ-1 X-MC-Unique: 84yGNyjENB-jJNOPGjGggw-1 From: zhangjl02 To: libvir-list@redhat.com Subject: [PATCHv2 3/4] qemu: interface: remove setting noqueue for ovs port Date: Thu, 1 Jul 2021 16:42:05 +0800 Message-Id: <20210701084206.621-4-jx8zjs@126.com> In-Reply-To: <20210701084206.621-1-jx8zjs@126.com> References: <20210701084206.621-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DMmowAB3LRr6f91ggnb6Cg--.12121S5 X-Coremail-Antispam: 1Uf129KBjvdXoWrZF45GF13tryxWFy3Aw47urg_yoWfWFb_Aa 4rZa1UWF4kGF43Ar47AayfZryI9rs8Ja1kW34vgwnxJF48Cw4rGFs8Zws3Zr1Uua47WFWx XFs7uw13A3srCjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU59mitUUUUU== X-Originating-IP: [58.56.96.28] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbikx-CSFpEB0kq6gAAsW 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.15 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 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. --- 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 fc60e15eea..b9485e4fe6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11526,7 +11526,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, actualType) && + virNetDevBandwidthSetRootQDisc(net->ifname, "noqueue") < 0) return -1; } =20 --=20 2.30.2.windows.1 From nobody Sun May 19 10:01:20 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 1625129062961424.8772177365281; Thu, 1 Jul 2021 01:44:22 -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-90-97fDJ_WtPo2jIvEzUI-2ZQ-1; Thu, 01 Jul 2021 04:44:19 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49CEB1084F53; Thu, 1 Jul 2021 08:44:13 +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 2392F26575; Thu, 1 Jul 2021 08:44: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 E38004EA37; Thu, 1 Jul 2021 08:44:12 +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 1618gq9t006289 for ; Thu, 1 Jul 2021 04:42:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1FFB710329B; Thu, 1 Jul 2021 08:42:52 +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 17DBDFED2A for ; Thu, 1 Jul 2021 08:42:47 +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 35A5A866DF8 for ; Thu, 1 Jul 2021 08:42:47 +0000 (UTC) Received: from m15112.mail.126.com (m15112.mail.126.com [220.181.15.112]) by relay.mimecast.com with ESMTP id us-mta-501-pxxiB0NENSmFL78ilpwnuA-1; Thu, 01 Jul 2021 04:42:45 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.28]) by smtp2 (Coremail) with SMTP id DMmowAB3LRr6f91ggnb6Cg--.12121S6; Thu, 01 Jul 2021 16:42:39 +0800 (CST) X-MC-Unique: 97fDJ_WtPo2jIvEzUI-2ZQ-1 X-MC-Unique: pxxiB0NENSmFL78ilpwnuA-1 From: zhangjl02 To: libvir-list@redhat.com Subject: [PATCHv2 4/4] qemu: interface: check and use ovs command to set qos of ovs managed port Date: Thu, 1 Jul 2021 16:42:06 +0800 Message-Id: <20210701084206.621-5-jx8zjs@126.com> In-Reply-To: <20210701084206.621-1-jx8zjs@126.com> References: <20210701084206.621-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DMmowAB3LRr6f91ggnb6Cg--.12121S6 X-Coremail-Antispam: 1Uf129KBjvJXoW3JFyUCF4fJF17GFWUKFW7urg_yoWxKw4kp3 WkGF95tr48XF4xJF43ua18ua43J3W09rZ3CFy7X340vw17JFy5Xr1fKw10v34Yvrs3Aa45 C3WUZa1DW3Wqk3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07b16wZUUUUU= X-Originating-IP: [58.56.96.28] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbiIR-CSFpEBzbjuAAAsA 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.84 on 10.5.11.23 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 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. --- src/qemu/qemu_command.c | 10 ++++++++-- src/qemu/qemu_driver.c | 22 +++++++++++++++++++++- src/qemu/qemu_hotplug.c | 39 ++++++++++++++++++++++++++++----------- src/qemu/qemu_process.c | 10 ++++++++-- 4 files changed, 65 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ea513693f7..1e9ed592e1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8610,8 +8610,14 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, actualBandwidth =3D virDomainNetGetActualBandwidth(net); if (actualBandwidth) { if (virNetDevSupportsBandwidth(actualType)) { - if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false, - !virDomainNetTypeSharesHostView(net)= ) < 0) + if (virDomainNetDefIsOvsport(net, actualType)) { + if (virNetDevOpenvswitchInterfaceSetQos(net->ifname, actua= lBandwidth, + def->uuid, + !virDomainNetTypeS= haresHostView(net)) < 0) + goto cleanup; + } + else if (virNetDevBandwidthSet(net->ifname, actualBandwidth, f= alse, + !virDomainNetTypeSharesHostView= (net)) < 0) goto cleanup; } else { VIR_WARN("setting bandwidth on interfaces of " diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 235f575901..a6212fed6a 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, actualType); } =20 if (qosSupported && persistentNet) { @@ -10366,7 +10368,25 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, } } =20 - if (virNetDevBandwidthSet(net->ifname, newBandwidth, false, + 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(net)) < = 0) { virErrorPtr orig_err; =20 diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d2a354d026..e900834e3e 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) - goto cleanup; + if (virDomainNetDefIsOvsport(net, actualType)) { + if (virNetDevOpenvswitchInterfaceSetQos(net->ifname, actua= lBandwidth, + vm->def->uuid, + !virDomainNetTypeS= haresHostView(net)) < 0) + goto cleanup; + } + else if (virNetDevBandwidthSet(net->ifname, actualBandwidth, f= alse, + !virDomainNetTypeSharesHostView(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) - goto cleanup; + if (virDomainNetDefIsOvsport(newdev, newType)) { + if (virNetDevOpenvswitchInterfaceSetQos(newdev->ifname, ne= wb, + vm->def->uuid, + !virDomainNetTypeS= haresHostView(newdev)) < 0) + goto cleanup; + } + else if (virNetDevBandwidthSet(newdev->ifname, newb, false, + !virDomainNetTypeSharesHostView(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, actualType)) { + 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..95cdf232ef 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7818,6 +7818,7 @@ void qemuProcessStop(virQEMUDriver *driver, g_autofree char *timestamp =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(virConnect) conn =3D NULL; + int actualType; =20 VIR_DEBUG("Shutting down vm=3D%p name=3D%s id=3D%d pid=3D%lld, " "reason=3D%s, asyncJob=3D%s, flags=3D0x%x", @@ -7966,8 +7967,8 @@ 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)) { + actualType =3D virDomainNetGetActualType(net); + switch (actualType) { case VIR_DOMAIN_NET_TYPE_DIRECT: ignore_value(virNetDevMacVLanDeleteWithVPortProfile( net->ifname, &net->mac, @@ -8023,6 +8024,11 @@ void qemuProcessStop(virQEMUDriver *driver, else VIR_WARN("Unable to release network device '%s'", NULLSTR(= net->ifname)); } + if (virDomainNetDefIsOvsport(net, actualType)) { + if (virNetDevOpenvswitchInterfaceClearQos(net->ifname, vm->def= ->uuid) < 0) + VIR_WARN("cannot clear bandwidth setting for ovs device : = %s", + net->ifname); + } } =20 retry: --=20 2.30.2.windows.1