From nobody Sat May 4 00:29:06 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 1624873786649403.59970877855403; Mon, 28 Jun 2021 02:49:46 -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-600-b2i9OYRBPHORILBgFV9anw-1; Mon, 28 Jun 2021 05:49:43 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id ACAD4804B83; Mon, 28 Jun 2021 09:49:36 +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 8D2135D9C6; Mon, 28 Jun 2021 09:49:36 +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 3D9D91809CB2; Mon, 28 Jun 2021 09:49:36 +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 15S9nDQo008647 for ; Mon, 28 Jun 2021 05:49:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 520004C83B; Mon, 28 Jun 2021 09:49:13 +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 4CA884C83D for ; Mon, 28 Jun 2021 09:49:10 +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 8A147185A7A4 for ; Mon, 28 Jun 2021 09:49:10 +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-247-WbpoCR7tODGTFQ4nOEKuyw-1; Mon, 28 Jun 2021 05:49:08 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.28]) by smtp2 (Coremail) with SMTP id DMmowAB3fVXik9lg0G6wCg--.64150S3; Mon, 28 Jun 2021 17:18:40 +0800 (CST) X-MC-Unique: b2i9OYRBPHORILBgFV9anw-1 X-MC-Unique: WbpoCR7tODGTFQ4nOEKuyw-1 From: zhangjl02 To: libvir-list@redhat.com Subject: [PATCH 1/4] qemu: interface: add qemuDomainDefIsOvsport Date: Mon, 28 Jun 2021 17:18:20 +0800 Message-Id: <20210628091823.2345-2-jx8zjs@126.com> In-Reply-To: <20210628091823.2345-1-jx8zjs@126.com> References: <20210628091823.2345-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DMmowAB3fVXik9lg0G6wCg--.64150S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Aw4fJw1DXw48uFWxAFWUJwb_yoW8Gr1kpa nrJas3Jr4FgF47ZFZ3CayUuF15GryvqFnFkrW3Wr1vqr17JF1Durn3ZF1v9FyDArZxCFW7 CFW7CrWUCFn8taDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jTT5dUUUUU= X-Originating-IP: [58.56.96.28] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbi2RC-SFpEB02RFAAAsv 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 X-Mailman-Approved-At: Mon, 28 Jun 2021 05:49:29 -0400 Cc: zhangjl02 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.14 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/qemu/qemu_domain.c | 13 +++++++++++++ src/qemu/qemu_domain.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index fc60e15eea..da5a226fc2 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11575,3 +11575,16 @@ qemuDomainNamePathsCleanup(virQEMUDriverConfig *cf= g, =20 return 0; } + +/* + * Check whether the port is an ovs managed port + */ +bool qemuDomainDefIsOvsport(virDomainNetDef *net, + int actualType) { + const virNetDevVPortProfile *vport =3D virDomainNetGetActualVirtPortPr= ofile(net); + if ((actualType =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE) && vport && + vport->virtPortType =3D=3D VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) { + return true; + } + return false; +} \ No newline at end of file diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index acf6ca5ab6..81a9bf0cfb 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1063,3 +1063,6 @@ int qemuDomainNamePathsCleanup(virQEMUDriverConfig *cfg, const char *name, bool bestEffort); + +bool qemuDomainDefIsOvsport(virDomainNetDef *net, + int actualType); \ No newline at end of file --=20 2.30.2.windows.1 From nobody Sat May 4 00:29:06 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 1624873787727370.16192524214375; Mon, 28 Jun 2021 02:49:47 -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-28-e9skOBHiPuutIWoOIwODRA-1; Mon, 28 Jun 2021 05:49:44 -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 9F4B1106B7DE; Mon, 28 Jun 2021 09:49:39 +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 76FC41A26A; Mon, 28 Jun 2021 09:49:39 +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 112AA1809CB4; Mon, 28 Jun 2021 09:49:39 +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 15S9nDms008646 for ; Mon, 28 Jun 2021 05:49:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 523B24E3C4; Mon, 28 Jun 2021 09:49:13 +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 4C7234C834 for ; Mon, 28 Jun 2021 09:49:09 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 CD1F689C7DD for ; Mon, 28 Jun 2021 09:49:09 +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-401-TSEYFPONOg2PhIWswvETcA-1; Mon, 28 Jun 2021 05:49:05 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.28]) by smtp2 (Coremail) with SMTP id DMmowAB3fVXik9lg0G6wCg--.64150S4; Mon, 28 Jun 2021 17:18:40 +0800 (CST) X-MC-Unique: e9skOBHiPuutIWoOIwODRA-1 X-MC-Unique: TSEYFPONOg2PhIWswvETcA-1 From: zhangjl02 To: libvir-list@redhat.com Subject: [PATCH 2/4] qemu: interface: add virNetDevOpenvswitchInterfaceSetQos and virNetDevOpenvswitchInterfaceClearQos Date: Mon, 28 Jun 2021 17:18:21 +0800 Message-Id: <20210628091823.2345-3-jx8zjs@126.com> In-Reply-To: <20210628091823.2345-1-jx8zjs@126.com> References: <20210628091823.2345-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DMmowAB3fVXik9lg0G6wCg--.64150S4 X-Coremail-Antispam: 1Uf129KBjvAXoW3Cw4DGr17GF43Cr13ZrW7XFb_yoW8JF13Ao W3Gr47Kr1DW34UuanYyan7G3yUAr15KrsxWr4Y9ayDJry8Gr9YvrykAan8AFsaqFW8Ar17 WF1SgrW3GFsxCw1fn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73VFW2AGmfu7bjvjm3 AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjxUTFApUUUUU X-Originating-IP: [58.56.96.28] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbinxG-SFpEB0CGDwAAsp 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 X-Mailman-Approved-At: Mon, 28 Jun 2021 05:49:29 -0400 Cc: zhangjl02 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 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 | 269 ++++++++++++++++++++++++++++++++ src/util/virnetdevopenvswitch.h | 11 ++ 3 files changed, 282 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 68e4b6aab8..775f6706b3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2805,8 +2805,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..f27b74f35f 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,268 @@ 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) +{ + int ret =3D -1; + char vmuuidstr[VIR_UUID_STRING_BUFLEN]; + virNetDevBandwidthRate *rx =3D NULL; /* From domain POV */ + virNetDevBandwidthRate *tx =3D NULL; /* From domain POV */ + virCommand *cmd =3D NULL; + char *vmid_ex_id =3D NULL; + char *ifname_ex_id =3D NULL; + char *average =3D NULL; + char *peak =3D NULL; + char *burst =3D NULL; + char *qos_uuid =3D NULL; + char *queue_uuid =3D NULL; + char **lines =3D NULL; + + if (!bandwidth) { + /* nothing to be enabled */ + ret =3D 0; + goto cleanup; + } + + 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) { + ret =3D virNetDevOpenvswitchInterfaceClearQos(ifname, vmid); + // virNetDevBandwidthClear(iframe); + } + 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) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to find queue on port %s"), ifname); + } + + // find qos + 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) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to find qos on port %s"), ifname); + } + + // create qos and set + 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); + } + else + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to create and set qos configurati= on on port %s"), ifname); + goto cleanup; + } + + if(qos_uuid && *qos_uuid){ + 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); + goto cleanup; + } + } + + // ret =3D virNetDevBandwidthSet(ifname,bandwidth,false,swapped); + } + + if (rx) { + average =3D g_strdup_printf("%llu", rx->average * 8); + if (rx->burst) + burst =3D g_strdup_printf("%llu", rx->burst * 8); + 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); + goto cleanup; + } + } + + return 0; + + cleanup: + virCommandFree(cmd); + VIR_FREE(average); + VIR_FREE(peak); + VIR_FREE(burst); + VIR_FREE(qos_uuid); + VIR_FREE(queue_uuid); + VIR_FREE(vmid_ex_id); + VIR_FREE(ifname_ex_id); + VIR_FREE(lines); + return ret; +} + +int virNetDevOpenvswitchInterfaceClearQos(const char *ifname, + const unsigned char *vmid){ + char vmuuidstr[VIR_UUID_STRING_BUFLEN]; + virCommand *cmd =3D NULL; + char *vmid_ex_id =3D NULL; + char *qos_uuid =3D NULL; + char *queue_uuid =3D NULL; + 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) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to find qos on port %s"), ifname); + } + + // find queue + 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) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("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; + } + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "remove", "port", ifname, "qos", lin= e, NULL); + if (virCommandRun(cmd, NULL) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to remove port qos on port %s"), = ifname); + } + 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); + } + } + } + // 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; + } + 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); + } + } + } + + virCommandFree(cmd); + VIR_FREE(qos_uuid); + VIR_FREE(queue_uuid); + VIR_FREE(vmid_ex_id); + VIR_FREE(lines); + 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 Sat May 4 00:29:06 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 1624873785041669.4504195180997; Mon, 28 Jun 2021 02:49:45 -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-586-fDh3qkYUPu6Ki_hCP50S2g-1; Mon, 28 Jun 2021 05:49:41 -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 B413250765; Mon, 28 Jun 2021 09:49:36 +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 8BCC21A26A; Mon, 28 Jun 2021 09:49:36 +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 3D13C4EA3A; Mon, 28 Jun 2021 09:49:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15S9nBt3008636 for ; Mon, 28 Jun 2021 05:49:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 685FC215CDD1; Mon, 28 Jun 2021 09:49:11 +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 636D2215CDD3 for ; Mon, 28 Jun 2021 09:49:08 +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 7FFF389C7DB for ; Mon, 28 Jun 2021 09:49:08 +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-558--skSRBcQNSKUnPKpeGvqMg-1; Mon, 28 Jun 2021 05:49:05 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.28]) by smtp2 (Coremail) with SMTP id DMmowAB3fVXik9lg0G6wCg--.64150S5; Mon, 28 Jun 2021 17:18:41 +0800 (CST) X-MC-Unique: fDh3qkYUPu6Ki_hCP50S2g-1 X-MC-Unique: -skSRBcQNSKUnPKpeGvqMg-1 From: zhangjl02 To: libvir-list@redhat.com Subject: [PATCH 3/4] qemu: interface: remove setting noqueue for ovs port Date: Mon, 28 Jun 2021 17:18:22 +0800 Message-Id: <20210628091823.2345-4-jx8zjs@126.com> In-Reply-To: <20210628091823.2345-1-jx8zjs@126.com> References: <20210628091823.2345-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DMmowAB3fVXik9lg0G6wCg--.64150S5 X-Coremail-Antispam: 1Uf129KBjvdXoWrZF45GF13trW7Kr48uw1fCrg_yoW3ZFX_A3 WFva1UXFZ5GFsxCrW7ua4fXry09rn8Ja1kW3s2gan3JF1Uuw4rJFZ8Zws3Zr1UZa47GFyx XFn7Kw1fA34DCjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU5bYFtUUUUU== X-Originating-IP: [58.56.96.28] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbi2RG-SFpEB02RFwAAst 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.6 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Mon, 28 Jun 2021 05:49:29 -0400 Cc: zhangjl02 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 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index da5a226fc2..2e8236ce7c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11526,6 +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 (qemuDomainDefIsOvsport(net, actualType)) + return 0; if (virNetDevBandwidthSetRootQDisc(net->ifname, "noqueue") < 0) return -1; } --=20 2.30.2.windows.1 From nobody Sat May 4 00:29:06 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 1624873780710468.5988532588665; Mon, 28 Jun 2021 02:49:40 -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-454-qOn9xPLiNcyIkpK61emWIQ-1; Mon, 28 Jun 2021 05:49:36 -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 E7590804311; Mon, 28 Jun 2021 09:49:31 +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 BBFB826FD1; Mon, 28 Jun 2021 09:49:31 +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 E9A924EA2A; Mon, 28 Jun 2021 09:49:30 +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 15S9nBYx008635 for ; Mon, 28 Jun 2021 05:49:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 46483201C0DE; Mon, 28 Jun 2021 09:49:11 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 415CC2024CDA for ; Mon, 28 Jun 2021 09:49:08 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 43A5C8007BB for ; Mon, 28 Jun 2021 09:49:08 +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-273-IF56fIXhM5aQ6dU3xrJtwA-1; Mon, 28 Jun 2021 05:49:05 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.28]) by smtp2 (Coremail) with SMTP id DMmowAB3fVXik9lg0G6wCg--.64150S6; Mon, 28 Jun 2021 17:18:41 +0800 (CST) X-MC-Unique: qOn9xPLiNcyIkpK61emWIQ-1 X-MC-Unique: IF56fIXhM5aQ6dU3xrJtwA-1 From: zhangjl02 To: libvir-list@redhat.com Subject: [PATCH 4/4] qemu: interface: check and use ovs command to set qos of ovs managed port Date: Mon, 28 Jun 2021 17:18:23 +0800 Message-Id: <20210628091823.2345-5-jx8zjs@126.com> In-Reply-To: <20210628091823.2345-1-jx8zjs@126.com> References: <20210628091823.2345-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DMmowAB3fVXik9lg0G6wCg--.64150S6 X-Coremail-Antispam: 1Uf129KBjvJXoW3JFyUCF4xAry7Ary3ur4Durg_yoW3Jw4xpF 18GF95tr4rXr4xJF43ua18ua43J3W09r93CFy7X340vw17JFy5Xr1fKw10v34Yvrs3Aa45 Ca4UZa1Du3Wqk3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07bUuWLUUUUU= X-Originating-IP: [58.56.96.28] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbi1xG-SF53WhgzwgAAsr 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 X-Mailman-Approved-At: Mon, 28 Jun 2021 05:49:29 -0400 Cc: zhangjl02 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 | 21 ++++++++++++++++++++- src/qemu/qemu_hotplug.c | 39 ++++++++++++++++++++++++++++----------- src/qemu/qemu_process.c | 11 +++++++++-- 4 files changed, 65 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ea513693f7..35085f293c 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 (qemuDomainDefIsOvsport(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..eefb67b404 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 qemuDomainDefIsOvsport(net, actualType); } =20 if (qosSupported && persistentNet) { @@ -10366,7 +10368,24 @@ 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..4cf74072bc 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 (qemuDomainDefIsOvsport(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 (qemuDomainDefIsOvsport(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 (qemuDomainDefIsOvsport(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..3499f4548c 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,12 @@ void qemuProcessStop(virQEMUDriver *driver, else VIR_WARN("Unable to release network device '%s'", NULLSTR(= net->ifname)); } + if ((actualType =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || actualType = =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT) && vport && + vport->virtPortType =3D=3D VIR_NETDEV_VPORT_PROFILE_OPENVSWITC= H) { + 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