From nobody Mon Feb 9 17:35:26 2026 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 1628474870343282.1469380853381; Sun, 8 Aug 2021 19:07:50 -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-100-lQygrzJKNO-cxdF3jFNezg-1; Sun, 08 Aug 2021 22:07:47 -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 D54AD1084F4B; Mon, 9 Aug 2021 02:07:42 +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 ADD7E66FFF; Mon, 9 Aug 2021 02:07:42 +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 4F6C4180BAB1; Mon, 9 Aug 2021 02:07:42 +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 17926GRZ010527 for ; Sun, 8 Aug 2021 22:06:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7051B568E6; Mon, 9 Aug 2021 02:06:16 +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 6B257568E4 for ; Mon, 9 Aug 2021 02:06:12 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 A68B78CA942 for ; Mon, 9 Aug 2021 02:06:12 +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-548-0v7o_nFYMzuW2NnZQ9HDbg-1; Sun, 08 Aug 2021 22:06:10 -0400 Received: from zhangjl0200.home.langchao.com (unknown [223.104.194.187]) by smtp3 (Coremail) with SMTP id DcmowAAnd8OMjRBhXsB1Tw--.2037S3; Mon, 09 Aug 2021 10:06:06 +0800 (CST) X-MC-Unique: lQygrzJKNO-cxdF3jFNezg-1 X-MC-Unique: 0v7o_nFYMzuW2NnZQ9HDbg-1 From: zhangjl02 To: libvir-list@redhat.com Subject: [PATCH 1/2] virDomain: interface: add virNetDevOpenvswitchInterfaceClearTxQos and virNetDevOpenvswitchInterfaceClearRxQos. Date: Mon, 9 Aug 2021 10:05:59 +0800 Message-Id: <20210809020600.647-2-jx8zjs@126.com> In-Reply-To: <20210809020600.647-1-jx8zjs@126.com> References: <20210809020600.647-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DcmowAAnd8OMjRBhXsB1Tw--.2037S3 X-Coremail-Antispam: 1Uf129KBjvJXoW3Gr45Xry7tFWfAw1UWw17Jrb_yoWxKrW5pF y8Gr1DJw10vrsrGwsrCa10gryUtrZ5Wr1fAas8u3WUXw4DG34Svw47K3y7Aay5Cr4xJ3W5 AFZ5XFy8Aa4xJaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UlFAXUUUUU= X-Originating-IP: [223.104.194.187] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbi1w7pSF53WygArAABsP 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.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 X-ZM-MESSAGEID: 1628474872093100001 Content-Type: text/plain; charset="utf-8" From: Jinsheng Zhang Instead of cleaning all qos rules each time new qos is set, tx and rx's qos= can be set or clean respectively. Replace virReportError with VIR_WARN to let the cleaning process continue w= hen error occurs. Add ifname into ovs querying statements, which will reduce failure of remov= ing qos on the other interfaces of the same vm. Additionally, two problems is fixed. 1. Ingress rules is not clean on previous version of virNetDevOpenvswitchIn= terfaceClearQos. 2. If errors occurs when removing inbound qos on multi interfaces vm, some = rules may not be delete as aspected. Signed-off-by: zhangjl02 --- src/libvirt_private.syms | 2 + src/util/virnetdevopenvswitch.c | 69 +++++++++++++++++++++++++++------ src/util/virnetdevopenvswitch.h | 7 ++++ 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6fc8239d2e..7366919d6c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2816,6 +2816,8 @@ virNetDevOpenvswitchAddPort; virNetDevOpenvswitchGetMigrateData; virNetDevOpenvswitchGetVhostuserIfname; virNetDevOpenvswitchInterfaceClearQos; +virNetDevOpenvswitchInterfaceClearRxQos; +virNetDevOpenvswitchInterfaceClearTxQos; virNetDevOpenvswitchInterfaceGetMaster; virNetDevOpenvswitchInterfaceParseStats; virNetDevOpenvswitchInterfaceSetQos; diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index 7a64a8dbe6..af9c611905 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -778,6 +778,10 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifname, return -1; } } + } else { + if (virNetDevOpenvswitchInterfaceClearTxQos(ifname, vmid) < 0) { + VIR_WARN("Clean tx qos for interface %s failed", ifname); + } } =20 if (rx) { @@ -794,17 +798,23 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifnam= e, _("Unable to set vlan configuration on port %s"= ), ifname); return -1; } + } else { + if (virNetDevOpenvswitchInterfaceClearRxQos(ifname) < 0) { + VIR_WARN("Clean rx qos for interface %s failed", ifname); + } } =20 return 0; } =20 int -virNetDevOpenvswitchInterfaceClearQos(const char *ifname, - const unsigned char *vmid) +virNetDevOpenvswitchInterfaceClearTxQos(const char *ifname, + const unsigned char *vmid) { + int ret =3D 0; char vmuuidstr[VIR_UUID_STRING_BUFLEN]; g_autoptr(virCommand) cmd =3D NULL; + g_autofree char *ifname_ex_id =3D NULL; g_autofree char *vmid_ex_id =3D NULL; g_autofree char *qos_uuid =3D NULL; g_autofree char *queue_uuid =3D NULL; @@ -815,7 +825,8 @@ virNetDevOpenvswitchInterfaceClearQos(const char *ifnam= e, 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); + ifname_ex_id =3D g_strdup_printf("external-ids:ifname=3D\"%s\"", ifnam= e); + virCommandAddArgList(cmd, "--no-heading", "--columns=3D_uuid", "find",= "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); @@ -825,7 +836,7 @@ virNetDevOpenvswitchInterfaceClearQos(const char *ifnam= e, 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); + virCommandAddArgList(cmd, "--no-heading", "--columns=3D_uuid", "find",= "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); @@ -843,7 +854,7 @@ virNetDevOpenvswitchInterfaceClearQos(const char *ifnam= e, virCommandFree(cmd); cmd =3D virNetDevOpenvswitchCreateCmd(); virCommandAddArgList(cmd, "--no-heading", "--columns=3D_uuid",= "--if-exists", - "list", "port", ifname, "qos", NULL); + "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); @@ -860,9 +871,8 @@ virNetDevOpenvswitchInterfaceClearQos(const char *ifnam= e, 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; + VIR_WARN("Unable to destroy qos on port %s", ifname); + ret =3D -1; } } } @@ -879,12 +889,49 @@ virNetDevOpenvswitchInterfaceClearQos(const char *ifn= ame, 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; + VIR_WARN("Unable to destroy queue on port %s", ifname); + ret =3D -1; } } } =20 + return ret; +} + +int +virNetDevOpenvswitchInterfaceClearRxQos(const char *ifname) +{ + g_autoptr(virCommand) cmd =3D NULL; + + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "set", "Interface", ifname, NULL); + virCommandAddArgFormat(cmd, "ingress_policing_rate=3D%llu", 0llu); + virCommandAddArgFormat(cmd, "ingress_policing_burst=3D%llu", 0llu); + + if (virCommandRun(cmd, NULL) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to set vlan configuration on port %s"), i= fname); + return -1; + } + return 0; } + +int +virNetDevOpenvswitchInterfaceClearQos(const char *ifname, + const unsigned char *vmid) +{ + int ret =3D 0; + + if (virNetDevOpenvswitchInterfaceClearTxQos(ifname, vmid) < 0) { + VIR_WARN("Clean tx qos for interface %s failed", ifname); + ret =3D -1; + } + + if (virNetDevOpenvswitchInterfaceClearRxQos(ifname) < 0) { + VIR_WARN("Clean rx qos for interface %s failed", ifname); + ret =3D -1; + } + + return ret; +} diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitc= h.h index 2dcd1aec6b..d44072cc8c 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -80,3 +80,10 @@ int virNetDevOpenvswitchInterfaceSetQos(const char *ifna= me, int virNetDevOpenvswitchInterfaceClearQos(const char *ifname, const unsigned char *vmid) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; + +int virNetDevOpenvswitchInterfaceClearRxQos(const char *ifname) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; + +int virNetDevOpenvswitchInterfaceClearTxQos(const char *ifname, + const unsigned char *vmid) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; --=20 2.30.2.windows.1