From nobody Mon Apr 29 16:50:54 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 1629175443441942.2705816461823; Mon, 16 Aug 2021 21:44:03 -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-447-MFiM3wWTO6Gz8uCEa0iXnw-1; Tue, 17 Aug 2021 00:39:46 -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 32E081008060; Tue, 17 Aug 2021 04:39:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C7B119C44; Tue, 17 Aug 2021 04:39:41 +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 DB43B181A100; Tue, 17 Aug 2021 04:39:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17H4dJ8b016908 for ; Tue, 17 Aug 2021 00:39:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 06CA1201B070; Tue, 17 Aug 2021 04:39:19 +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 01BD6201B06E for ; Tue, 17 Aug 2021 04:39:15 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.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 9D928802A64 for ; Tue, 17 Aug 2021 04:39:15 +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-398-fGokorksOFmypctnAbGsBw-1; Tue, 17 Aug 2021 00:39:13 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.27]) by smtp3 (Coremail) with SMTP id DcmowAAX7FtqPRthCBo2AQ--.7384S3; Tue, 17 Aug 2021 12:39:09 +0800 (CST) X-MC-Unique: MFiM3wWTO6Gz8uCEa0iXnw-1 X-MC-Unique: fGokorksOFmypctnAbGsBw-1 From: jx8zjs To: libvir-list@redhat.com Subject: [PATCHv2 1/6] virnetdevovs: Add vmuuid notes on virNetDevOpenvswitchInterfaceSetQos Date: Tue, 17 Aug 2021 12:38:11 +0800 Message-Id: <20210817043816.1109-2-jx8zjs@126.com> In-Reply-To: <20210817043816.1109-1-jx8zjs@126.com> References: <20210817043816.1109-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DcmowAAX7FtqPRthCBo2AQ--.7384S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxXryfuFW5Jr4fXFWkurW8Xrb_yoW5Xw4xpr WkKFyDJw10kr13W3WDCF40gr1Utry8Gr1Skas8Zay7Zr4DXr9aqw43K3y2yay5ur4xJ3Wr AFZ5WrykAa4IyFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j4xRfUUUUU= X-Originating-IP: [58.56.96.27] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbiFw3xSFpEB8NtbAAAs4 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.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 X-ZM-MESSAGEID: 1629175443865100001 Content-Type: text/plain; charset="utf-8" From: Jinsheng Zhang Add vmuuid notes on virNetDevOpenvswitchInterfaceSetQos, and change vmid to vmuuid. Signed-off-by: Jinsheng Zhang Reviewed-by: Michal Privoznik --- src/util/virnetdevopenvswitch.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index 7a64a8dbe6..d86ad0eafd 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -624,6 +624,7 @@ int virNetDevOpenvswitchUpdateVlan(const char *ifname, * virNetDevOpenvswitchInterfaceSetQos: * @ifname: on which interface * @bandwidth: rates to set (may be NULL) + * @vmuuid: the Domain UUID that has this interface * @swapped: true if IN/OUT should be set contrariwise * * Update qos configuration of an OVS port. @@ -640,7 +641,7 @@ int virNetDevOpenvswitchUpdateVlan(const char *ifname, int virNetDevOpenvswitchInterfaceSetQos(const char *ifname, const virNetDevBandwidth *bandwidth, - const unsigned char *vmid, + const unsigned char *vmuuid, bool swapped) { virNetDevBandwidthRate *rx =3D NULL; /* From domain POV */ @@ -674,7 +675,7 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifname, } =20 if (!bandwidth->out && !bandwidth->in) { - if (virNetDevOpenvswitchInterfaceClearQos(ifname, vmid) < 0) { + if (virNetDevOpenvswitchInterfaceClearQos(ifname, vmuuid) < 0) { VIR_WARN("Clean qos for interface %s failed", ifname); } return 0; @@ -699,7 +700,7 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifname, =20 /* find queue */ cmd =3D virNetDevOpenvswitchCreateCmd(); - virUUIDFormat(vmid, vmuuidstr); + virUUIDFormat(vmuuid, 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", @@ -801,7 +802,7 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifname, =20 int virNetDevOpenvswitchInterfaceClearQos(const char *ifname, - const unsigned char *vmid) + const unsigned char *vmuuid) { char vmuuidstr[VIR_UUID_STRING_BUFLEN]; g_autoptr(virCommand) cmd =3D NULL; @@ -813,7 +814,7 @@ virNetDevOpenvswitchInterfaceClearQos(const char *ifnam= e, =20 /* find qos */ cmd =3D virNetDevOpenvswitchCreateCmd(); - virUUIDFormat(vmid, vmuuidstr); + virUUIDFormat(vmuuid, 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); --=20 2.30.2.windows.1 From nobody Mon Apr 29 16:50:54 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 162917517360021.198897593464835; Mon, 16 Aug 2021 21:39:33 -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-576-9pXepCl0PmaB7in_yAZItA-1; Tue, 17 Aug 2021 00:39:30 -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 20D331853026; Tue, 17 Aug 2021 04:39:25 +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 1CB593A47; Tue, 17 Aug 2021 04:39:24 +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 0D0B64BB7C; Tue, 17 Aug 2021 04:39:22 +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 17H4dIGQ016902 for ; Tue, 17 Aug 2021 00:39:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6859F215661D; Tue, 17 Aug 2021 04:39:18 +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 6353B2167810 for ; Tue, 17 Aug 2021 04:39:15 +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 DA0D889B846 for ; Tue, 17 Aug 2021 04:39:15 +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-512-opbeHkClOPaXMy6Z46VHmg-1; Tue, 17 Aug 2021 00:39:13 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.27]) by smtp3 (Coremail) with SMTP id DcmowAAX7FtqPRthCBo2AQ--.7384S4; Tue, 17 Aug 2021 12:39:10 +0800 (CST) X-MC-Unique: 9pXepCl0PmaB7in_yAZItA-1 X-MC-Unique: opbeHkClOPaXMy6Z46VHmg-1 From: jx8zjs To: libvir-list@redhat.com Subject: [PATCHv2 2/6] virnetdevovs: Extract conversion parameters between virNetDevBandwidth and ovs Date: Tue, 17 Aug 2021 12:38:12 +0800 Message-Id: <20210817043816.1109-3-jx8zjs@126.com> In-Reply-To: <20210817043816.1109-1-jx8zjs@126.com> References: <20210817043816.1109-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DcmowAAX7FtqPRthCBo2AQ--.7384S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7uFW5Jr45Ww1ruw4fKryDKFg_yoW5JF1Upa yxCryDtrsYqr1a939a9a10gry2yrWkJry3CFWDu3y5WF45Gr95Kr17KrWDAay5ZrW3J3WS qrs0yry8Aa4ftFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jTApnUUUUU= X-Originating-IP: [58.56.96.27] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbiIQ7xSFpECG9UpwAAsc 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 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: 1629175175793100001 Content-Type: text/plain; charset="utf-8" From: Jinsheng Zhang Signed-off-by: zhangjl02 Reviewed-by: Michal Privoznik --- src/util/virnetdevopenvswitch.c | 12 +++++++----- src/util/virnetdevopenvswitch.h | 7 +++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index d86ad0eafd..dfbebf8535 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -692,11 +692,11 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifnam= e, g_autofree char *qos_uuid =3D NULL; g_autofree char *queue_uuid =3D NULL; =20 - average =3D g_strdup_printf("%llu", tx->average * 8192); + average =3D g_strdup_printf("%llu", tx->average * VIR_NETDEV_TX_TO= _OVS); if (tx->burst) - burst =3D g_strdup_printf("%llu", tx->burst * 8192); + burst =3D g_strdup_printf("%llu", tx->burst * VIR_NETDEV_TX_TO= _OVS); if (tx->peak) - peak =3D g_strdup_printf("%llu", tx->peak * 8192); + peak =3D g_strdup_printf("%llu", tx->peak * VIR_NETDEV_TX_TO_O= VS); =20 /* find queue */ cmd =3D virNetDevOpenvswitchCreateCmd(); @@ -786,9 +786,11 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifname, =20 cmd =3D virNetDevOpenvswitchCreateCmd(); virCommandAddArgList(cmd, "set", "Interface", ifname, NULL); - virCommandAddArgFormat(cmd, "ingress_policing_rate=3D%llu", rx->av= erage * 8); + virCommandAddArgFormat(cmd, "ingress_policing_rate=3D%llu", + rx->average * VIR_NETDEV_RX_TO_OVS); if (rx->burst) - virCommandAddArgFormat(cmd, "ingress_policing_burst=3D%llu", r= x->burst * 8); + virCommandAddArgFormat(cmd, "ingress_policing_burst=3D%llu", + rx->burst * VIR_NETDEV_RX_TO_OVS); =20 if (virCommandRun(cmd, NULL) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitc= h.h index 2dcd1aec6b..33e52f57c7 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -26,6 +26,13 @@ #include "virnetdevvlan.h" =20 #define VIR_NETDEV_OVS_DEFAULT_TIMEOUT 5 +/* + * Average, peak, floor and burst in virNetDevBandwidth are in kbytes. + * However other_config in ovs qos is in bit. + * ingress_policing_rate in ovs interface is in kbit. + */ +#define VIR_NETDEV_TX_TO_OVS 8192 +#define VIR_NETDEV_RX_TO_OVS 8 =20 void virNetDevOpenvswitchSetTimeout(unsigned int timeout); =20 --=20 2.30.2.windows.1 From nobody Mon Apr 29 16:50:54 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 1629175228848689.3807740207586; Mon, 16 Aug 2021 21:40:28 -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-396-1aCzgKhxNhS6curmXFEe3g-1; Tue, 17 Aug 2021 00:39:45 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 525BF1853028; Tue, 17 Aug 2021 04:39:40 +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 2D748100763B; Tue, 17 Aug 2021 04:39:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E578A181A137; Tue, 17 Aug 2021 04:39:39 +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 17H4dOwq016966 for ; Tue, 17 Aug 2021 00:39:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id F0AA510087E1; Tue, 17 Aug 2021 04:39:23 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E9ACF114B2E6 for ; Tue, 17 Aug 2021 04:39:16 +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 7BF65101A52C for ; Tue, 17 Aug 2021 04:39:16 +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-542-8X8X-WG7Ml60iyinU_AHNA-1; Tue, 17 Aug 2021 00:39:13 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.27]) by smtp3 (Coremail) with SMTP id DcmowAAX7FtqPRthCBo2AQ--.7384S5; Tue, 17 Aug 2021 12:39:10 +0800 (CST) X-MC-Unique: 1aCzgKhxNhS6curmXFEe3g-1 X-MC-Unique: 8X8X-WG7Ml60iyinU_AHNA-1 From: jx8zjs To: libvir-list@redhat.com Subject: [PATCHv2 3/6] virnetdevovs: Extract common code block to a single function Date: Tue, 17 Aug 2021 12:38:13 +0800 Message-Id: <20210817043816.1109-4-jx8zjs@126.com> In-Reply-To: <20210817043816.1109-1-jx8zjs@126.com> References: <20210817043816.1109-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DcmowAAX7FtqPRthCBo2AQ--.7384S5 X-Coremail-Antispam: 1Uf129KBjvJXoWxCr17Ww13CFyxZr17Cw15Arb_yoWrKFy5pa yxGr1kJw10yr47WwnrCF1vgry7trWkGa43JFZI93WUXr4DW392qw47K3yxCas8uFWUJ3Wr AFZY9Fy8Aa4fJFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jmUDXUUUUU= X-Originating-IP: [58.56.96.27] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbiFw7xSFpEB8NtdgAAsh 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.84 on 10.5.11.22 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: 1629175230596100001 Content-Type: text/plain; charset="utf-8" From: Jinsheng Zhang Signed-off-by: zhangjl02 s Signed-off-by: zhangjl02 s Signed-off-by: zhangjl02 Reviewed-by: Michal Privoznik --- src/util/virnetdevopenvswitch.c | 60 ++++++++++++++------------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index dfbebf8535..e8ec06d3db 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -619,6 +619,23 @@ int virNetDevOpenvswitchUpdateVlan(const char *ifname, return 0; } =20 +static char* +virNetDevOpenvswitchFindUUID(const char *table, + const char *vmid_ex_id, + const char *ifname_ex_id) +{ + g_autoptr(virCommand) cmd =3D NULL; + char *uuid =3D NULL; + + cmd =3D virNetDevOpenvswitchCreateCmd(); + virCommandAddArgList(cmd, "--no-heading", "--columns=3D_uuid", "find",= table, + vmid_ex_id, ifname_ex_id, NULL); + virCommandSetOutputBuffer(cmd, &uuid); + if (virCommandRun(cmd, NULL) < 0) { + VIR_WARN("Unable to find queue on port with %s", ifname_ex_id); + } + return uuid; +} =20 /** * virNetDevOpenvswitchInterfaceSetQos: @@ -698,30 +715,15 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifnam= e, if (tx->peak) peak =3D g_strdup_printf("%llu", tx->peak * VIR_NETDEV_TX_TO_O= VS); =20 - /* find queue */ - cmd =3D virNetDevOpenvswitchCreateCmd(); virUUIDFormat(vmuuid, 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 queue */ + queue_uuid =3D virNetDevOpenvswitchFindUUID("queue", vmid_ex_id, i= fname_ex_id); /* 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); - } + qos_uuid =3D virNetDevOpenvswitchFindUUID("qos", vmid_ex_id, ifnam= e_ex_id); =20 /* create qos and set */ - virCommandFree(cmd); cmd =3D virNetDevOpenvswitchCreateCmd(); if (queue_uuid && *queue_uuid) { g_auto(GStrv) lines =3D g_strsplit(queue_uuid, "\n", 0); @@ -808,6 +810,7 @@ virNetDevOpenvswitchInterfaceClearQos(const char *ifnam= e, { 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,24 +818,13 @@ virNetDevOpenvswitchInterfaceClearQos(const char *ifn= ame, size_t i; =20 /* find qos */ - cmd =3D virNetDevOpenvswitchCreateCmd(); virUUIDFormat(vmuuid, 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); - } - + ifname_ex_id =3D g_strdup_printf("external-ids:ifname=3D\"%s\"", ifnam= e); /* 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); - } + queue_uuid =3D virNetDevOpenvswitchFindUUID("queue", vmid_ex_id, ifnam= e_ex_id); + /* find qos */ + qos_uuid =3D virNetDevOpenvswitchFindUUID("qos", vmid_ex_id, ifname_ex= _id); =20 if (qos_uuid && *qos_uuid) { g_auto(GStrv) lines =3D g_strsplit(qos_uuid, "\n", 0); @@ -846,7 +838,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); --=20 2.30.2.windows.1 From nobody Mon Apr 29 16:50:54 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 162917520127155.81844086754063; Mon, 16 Aug 2021 21:40:01 -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-197-heab9ZhtPZKmWrMD5hfoyQ-1; Tue, 17 Aug 2021 00:39:58 -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 333BD802B9F; Tue, 17 Aug 2021 04:39:52 +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 0C62B1AC80; Tue, 17 Aug 2021 04:39: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 CD74E4A704; Tue, 17 Aug 2021 04:39:51 +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 17H4dJhX016909 for ; Tue, 17 Aug 2021 00:39:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6338721449DE; Tue, 17 Aug 2021 04:39:19 +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 5E9EB21449D9 for ; Tue, 17 Aug 2021 04:39:19 +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 46B448007BB for ; Tue, 17 Aug 2021 04:39:19 +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-245-651HU7vQMJy9jmRzdsY2fA-1; Tue, 17 Aug 2021 00:39:14 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.27]) by smtp3 (Coremail) with SMTP id DcmowAAX7FtqPRthCBo2AQ--.7384S6; Tue, 17 Aug 2021 12:39:10 +0800 (CST) X-MC-Unique: heab9ZhtPZKmWrMD5hfoyQ-1 X-MC-Unique: 651HU7vQMJy9jmRzdsY2fA-1 From: jx8zjs To: libvir-list@redhat.com Subject: [PATCHv2 4/6] virnetdevovs: Introduce virNetDevOpenvswitchInterfaceClearTxQos and virNetDevOpenvswitchInterfaceClearRxQos Date: Tue, 17 Aug 2021 12:38:14 +0800 Message-Id: <20210817043816.1109-5-jx8zjs@126.com> In-Reply-To: <20210817043816.1109-1-jx8zjs@126.com> References: <20210817043816.1109-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DcmowAAX7FtqPRthCBo2AQ--.7384S6 X-Coremail-Antispam: 1Uf129KBjvJXoWxuF1fKw15JFWDAw17uF43Awb_yoWrWFW7pr ykGr90qw10yr1fGwnxCa10gryYyrWrWr1fAas8Z3WUXw4UJr9avw43KrW7Aa15Ar4xJ3Wr AFZ5Zry8Aa47JaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jOgAwUUUUU= X-Originating-IP: [58.56.96.27] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbi1w7xSF53W2ZQ9gAAsS 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 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: 1629175202943100003 Content-Type: text/plain; charset="utf-8" From: Jinsheng Zhang Separate virNetDevOpenvswitchInterfaceClearQos into two steps. When setting qos, we can set only rx or tx and the other one should be cleared. Signed-off-by: zhangjl02 Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 2 ++ src/util/virnetdevopenvswitch.c | 50 +++++++++++++++++++++++++++++++-- src/util/virnetdevopenvswitch.h | 7 +++++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 51a400ba59..841cd08435 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 e8ec06d3db..7c13e1764f 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -781,6 +781,10 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifname, return -1; } } + } else { + if (virNetDevOpenvswitchInterfaceClearTxQos(ifname, vmuuid) < 0) { + VIR_WARN("Clean tx qos for interface %s failed", ifname); + } } =20 if (rx) { @@ -799,14 +803,18 @@ 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 *vmuuid) +virNetDevOpenvswitchInterfaceClearTxQos(const char *ifname, + const unsigned char *vmuuid) { char vmuuidstr[VIR_UUID_STRING_BUFLEN]; g_autoptr(virCommand) cmd =3D NULL; @@ -883,3 +891,41 @@ virNetDevOpenvswitchInterfaceClearQos(const char *ifna= me, =20 return 0; } + +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 *vmuuid) +{ + int ret =3D 0; + + if (virNetDevOpenvswitchInterfaceClearTxQos(ifname, vmuuid) < 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 33e52f57c7..cea5f4616d 100644 --- a/src/util/virnetdevopenvswitch.h +++ b/src/util/virnetdevopenvswitch.h @@ -87,3 +87,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 *v= mid) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; --=20 2.30.2.windows.1 From nobody Mon Apr 29 16:50:54 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 1629175200502580.7573270897506; Mon, 16 Aug 2021 21:40: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-361-achrpGN7PsGrSxLXHqpITA-1; Tue, 17 Aug 2021 00:39:57 -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 1E58F1F2E2; Tue, 17 Aug 2021 04:39:48 +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 F17E55DA61; Tue, 17 Aug 2021 04:39:47 +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 C2BFF4A7CB; Tue, 17 Aug 2021 04:39:47 +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 17H4dLJP016941 for ; Tue, 17 Aug 2021 00:39:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 675981C5B9; Tue, 17 Aug 2021 04:39:21 +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 62B4DB300D for ; Tue, 17 Aug 2021 04:39:18 +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 BD450800FFB for ; Tue, 17 Aug 2021 04:39:18 +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-7-sFw3CQn0NT-7YiGxRHML8g-1; Tue, 17 Aug 2021 00:39:14 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.27]) by smtp3 (Coremail) with SMTP id DcmowAAX7FtqPRthCBo2AQ--.7384S7; Tue, 17 Aug 2021 12:39:10 +0800 (CST) X-MC-Unique: achrpGN7PsGrSxLXHqpITA-1 X-MC-Unique: sFw3CQn0NT-7YiGxRHML8g-1 From: jx8zjs To: libvir-list@redhat.com Subject: [PATCHv2 5/6] virnetdevovs: Fix qos cleaning residual on multi interfaces Date: Tue, 17 Aug 2021 12:38:15 +0800 Message-Id: <20210817043816.1109-6-jx8zjs@126.com> In-Reply-To: <20210817043816.1109-1-jx8zjs@126.com> References: <20210817043816.1109-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DcmowAAX7FtqPRthCBo2AQ--.7384S7 X-Coremail-Antispam: 1Uf129KBjvJXoW7tr1UKr1UCr1rGr4Dur4fAFb_yoW8ZF48pF W8G3yDXw1rJF47G39rCa1rW34jyrZ5WF15tas8uwnxWw48J3yFqr4ag3y7AayrArW3Ja13 AFZ8WFyrAa4xAaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jsCztUUUUU= X-Originating-IP: [58.56.96.27] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbiIQ7xSFpECG9UrwAAsU 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.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 X-ZM-MESSAGEID: 1629175200875100001 Content-Type: text/plain; charset="utf-8" From: Jinsheng Zhang Warn these error instead of return when removing qos or queues. This will avoid residual qos clearance on multiple interfaces. Signed-off-by: zhangjl02 Reviewed-by: Michal Privoznik --- src/util/virnetdevopenvswitch.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index 7c13e1764f..e014a158f1 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -816,6 +816,7 @@ int virNetDevOpenvswitchInterfaceClearTxQos(const char *ifname, const unsigned char *vmuuid) { + int ret =3D 0; char vmuuidstr[VIR_UUID_STRING_BUFLEN]; g_autoptr(virCommand) cmd =3D NULL; g_autofree char *ifname_ex_id =3D NULL; @@ -863,9 +864,8 @@ virNetDevOpenvswitchInterfaceClearTxQos(const char *ifn= ame, 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; } } } @@ -882,14 +882,13 @@ virNetDevOpenvswitchInterfaceClearTxQos(const char *i= fname, 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 0; + return ret; } =20 int @@ -904,7 +903,7 @@ virNetDevOpenvswitchInterfaceClearRxQos(const char *ifn= ame) =20 if (virCommandRun(cmd, NULL) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to set vlan configuration on port %s"), i= fname); + _("Unable to reset ingress on port %s"), ifname); return -1; } =20 --=20 2.30.2.windows.1 From nobody Mon Apr 29 16:50:54 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 1629175192032805.7528078394905; Mon, 16 Aug 2021 21:39:52 -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-212-oVxWpy6gMwaeMFaqjQBcvQ-1; Tue, 17 Aug 2021 00:39:48 -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 D5CF880430A; Tue, 17 Aug 2021 04:39:43 +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 AE13D19C44; Tue, 17 Aug 2021 04:39:43 +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 5D8A54BB7C; Tue, 17 Aug 2021 04:39:43 +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 17H4dJWd016918 for ; Tue, 17 Aug 2021 00:39:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9A44921449DF; Tue, 17 Aug 2021 04:39:19 +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 94C2121449D9 for ; Tue, 17 Aug 2021 04:39:19 +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 537D1800B28 for ; Tue, 17 Aug 2021 04:39:19 +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-246-WkFeNN-tOGONHztchPsNbA-1; Tue, 17 Aug 2021 00:39:15 -0400 Received: from zhangjl0200.home.langchao.com (unknown [58.56.96.27]) by smtp3 (Coremail) with SMTP id DcmowAAX7FtqPRthCBo2AQ--.7384S8; Tue, 17 Aug 2021 12:39:10 +0800 (CST) X-MC-Unique: oVxWpy6gMwaeMFaqjQBcvQ-1 X-MC-Unique: WkFeNN-tOGONHztchPsNbA-1 From: jx8zjs To: libvir-list@redhat.com Subject: [PATCHv2 6/6] tests: add test on virNetDevOpenvswitchInterfaceSetQos and virNetDevOpenvswitchInterfaceClearQos Date: Tue, 17 Aug 2021 12:38:16 +0800 Message-Id: <20210817043816.1109-7-jx8zjs@126.com> In-Reply-To: <20210817043816.1109-1-jx8zjs@126.com> References: <20210817043816.1109-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DcmowAAX7FtqPRthCBo2AQ--.7384S8 X-Coremail-Antispam: 1Uf129KBjvJXoW3Jr4kuFW3JF43KF1rXrW5Jrb_yoW3Ww1DpF sxG3Z0kr48Jr1xK3y7ur1rGrWUGr10kF48Ga4xW3y5trnxJryaqw17Ka1Ika1ayr4fX3s5 Xa15JFWqkw17taDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jsCztUUUUU= X-Originating-IP: [58.56.96.27] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbi2Q7xSFpECJuVxQAAsz 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 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 X-ZM-MESSAGEID: 1629175192462100001 Content-Type: text/plain; charset="utf-8" From: Jinsheng Zhang Test virNetDevOpenvswitchInterfaceSetQos and virNetDevOpenvswitchInterfaceClearQos with dryrun method. Signed-off-by: zhangjl02 Reviewed-by: Michal Privoznik --- tests/virnetdevopenvswitchtest.c | 196 ++++++++++++++++++++++++++++++- 1 file changed, 195 insertions(+), 1 deletion(-) diff --git a/tests/virnetdevopenvswitchtest.c b/tests/virnetdevopenvswitcht= est.c index 46172dae90..f7d16b4f67 100644 --- a/tests/virnetdevopenvswitchtest.c +++ b/tests/virnetdevopenvswitchtest.c @@ -19,7 +19,11 @@ #include =20 #include "testutils.h" +#define LIBVIRT_VIRCOMMANDPRIV_H_ALLOW +#include "vircommandpriv.h" +#include "virnetdevbandwidth.h" #include "virnetdevopenvswitch.h" +#include "netdev_bandwidth_conf.c" =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 @@ -29,6 +33,43 @@ struct _InterfaceParseStatsData { const virDomainInterfaceStatsStruct stats; }; =20 +struct testSetQosStruct { + const char *band; + const char *exp_cmd; + const char *iface; +}; + +struct testClearQosStruct { + const char *exp_cmd; + const char *iface; + const unsigned char *vmid; +}; + +#define PARSE(xml, var) \ + do { \ + int rc; \ + xmlDocPtr doc; \ + xmlXPathContextPtr ctxt =3D NULL; \ + \ + if (!xml) \ + break; \ + \ + if (!(doc =3D virXMLParseStringCtxt((xml), \ + "bandwidth definition", \ + &ctxt))) \ + goto cleanup; \ + \ + rc =3D virNetDevBandwidthParse(&(var), \ + NULL, \ + ctxt->node, \ + true); \ + xmlFreeDoc(doc); \ + xmlXPathFreeContext(ctxt); \ + if (rc < 0) \ + goto cleanup; \ + } while (0) + +static const unsigned char vm_id[VIR_UUID_BUFLEN] =3D "fakeuuid"; =20 static int testInterfaceParseStats(const void *opaque) @@ -111,6 +152,80 @@ testNameEscape(const void *opaque) } =20 =20 +static int +testVirNetDevOpenvswitchInterfaceSetQos(const void *data) +{ + int ret =3D -1; + const struct testSetQosStruct *info =3D data; + const char *iface =3D info->iface; + g_autoptr(virNetDevBandwidth) band =3D NULL; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + char *actual_cmd =3D NULL; + g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); + + PARSE(info->band, band); + + if (!iface) + iface =3D "tap-fake"; + + virCommandSetDryRun(dryRunToken, &buf, false, false, NULL, NULL); + + if (virNetDevOpenvswitchInterfaceSetQos(iface, band, vm_id, true) < 0) + goto cleanup; + + if (!(actual_cmd =3D virBufferContentAndReset(&buf))) { + /* This is interesting, no command has been executed. + * Maybe that's expected, actually. */ + } + + if (STRNEQ_NULLABLE(info->exp_cmd, actual_cmd)) { + virTestDifference(stderr, + NULLSTR(info->exp_cmd), + NULLSTR(actual_cmd)); + goto cleanup; + } + + ret =3D 0; + cleanup: + VIR_FREE(actual_cmd); + return ret; +} + + +static int +testVirNetDevOpenvswitchInterfaceClearQos(const void *data) +{ + int ret =3D -1; + const struct testClearQosStruct *info =3D data; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + char *actual_cmd =3D NULL; + const char *iface =3D info->iface; + const unsigned char *vmid =3D info->vmid; + g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); + + virCommandSetDryRun(dryRunToken, &buf, false, false, NULL, NULL); + + if (virNetDevOpenvswitchInterfaceClearQos(iface, vmid) < 0) + goto cleanup; + + if (!(actual_cmd =3D virBufferContentAndReset(&buf))) { + /* This is interesting, no command has been executed. + * Maybe that's expected, actually. */ + } + + if (STRNEQ_NULLABLE(info->exp_cmd, actual_cmd)) { + virTestDifference(stderr, + NULLSTR(info->exp_cmd), + NULLSTR(actual_cmd)); + goto cleanup; + } + + ret =3D 0; + cleanup: + VIR_FREE(actual_cmd); + return ret; +} + static int mymain(void) { @@ -146,7 +261,86 @@ mymain(void) TEST_NAME_ESCAPE("\"vhost\"user1\"", NULL); TEST_NAME_ESCAPE("\"\\\\", NULL); =20 +#define DO_TEST_SET(Band, Exp_cmd, ...) \ + do { \ + struct testSetQosStruct data =3D {.band =3D Band, \ + .exp_cmd =3D Exp_cmd, \ + __VA_ARGS__}; \ + if (virTestRun("virNetDevOpenvswitchInterfaceSetQos", \ + testVirNetDevOpenvswitchInterfaceSetQos, \ + &data) < 0) \ + ret =3D -1; \ + } while (0) + + DO_TEST_SET(("" + " " + ""), + (OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D_uuid = find queue" + " 'external-ids:vm-id=3D\"66616b65-7575-6964-00= 00-000000000000\"'" + " 'external-ids:ifname=3D\"tap-fake\"'\n" + OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D_uuid = find qos" + " 'external-ids:vm-id=3D\"66616b65-7575-6964-00= 00-000000000000\"'" + " 'external-ids:ifname=3D\"tap-fake\"'\n" + OVS_VSCTL " --timeout=3D5 set port tap-fake qos=3D@qos1" + " 'external-ids:vm-id=3D\"66616b65-7575-6964-00= 00-000000000000\"'" + " 'external-ids:ifname=3D\"tap-fake\"'" + " -- --id=3D@qos1 create qos type=3Dlinux-htb o= ther_config:min-rate=3D163840000" + " queues:0=3D@queue0 'external-ids:vm-id=3D\"66= 616b65-7575-6964-0000-000000000000\"'" + " 'external-ids:ifname=3D\"tap-fake\"'" + " -- --id=3D@queue0 create queue other_config:m= in-rate=3D163840000 " + "'external-ids:vm-id=3D\"66616b65-7575-6964-000= 0-000000000000\"'" + " 'external-ids:ifname=3D\"tap-fake\"'\n" + OVS_VSCTL " --timeout=3D5 set Interface tap-fake ingress_= policing_rate=3D0 ingress_policing_burst=3D0\n")); + + DO_TEST_SET(NULL, NULL); + + DO_TEST_SET("", NULL); + + DO_TEST_SET(("" + " " + ""), + (OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D_uuid = find queue" + " 'external-ids:vm-id=3D\"66616b65-7575-6964-00= 00-000000000000\"'" + " 'external-ids:ifname=3D\"tap-fake\"'\n" + OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D_uuid = find qos" + " 'external-ids:vm-id=3D\"66616b65-7575-6964-00= 00-000000000000\"'" + " 'external-ids:ifname=3D\"tap-fake\"'\n" + OVS_VSCTL " --timeout=3D5 set Interface tap-fake ingress_= policing_rate=3D0 ingress_policing_burst=3D0\n")); + + DO_TEST_SET(("" + " " + " " + ""), + (OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D_uuid = find queue" + " 'external-ids:vm-id=3D\"66616b65-7575-6964-00= 00-000000000000\"'" + " 'external-ids:ifname=3D\"tap-fake\"'\n" + OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D_uuid = find qos" + " 'external-ids:vm-id=3D\"66616b65-7575-6964-00= 00-000000000000\"'" + " 'external-ids:ifname=3D\"tap-fake\"'\n" + OVS_VSCTL " --timeout=3D5 set Interface tap-fake ingress_= policing_rate=3D40000\n")); + +#define DO_TEST_CLEAR_QOS(Iface, Vmid, Exp_cmd, ...) \ + do { \ + struct testClearQosStruct data =3D {.iface =3D Iface, \ + .vmid =3D Vmid, \ + .exp_cmd =3D Exp_cmd, \ + __VA_ARGS__}; \ + if (virTestRun("virNetDevOpenvswitchInterfaceClearQos", \ + testVirNetDevOpenvswitchInterfaceClearQos, \ + &data) < 0) \ + ret =3D -1; \ + } while (0) + + DO_TEST_CLEAR_QOS(("fake-iface"), vm_id, + (OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D= _uuid find queue" + " 'external-ids:vm-id=3D\"66616b65-7575-6= 964-0000-000000000000\"'" + " 'external-ids:ifname=3D\"fake-iface\"'\= n" + OVS_VSCTL " --timeout=3D5 --no-heading --columns=3D= _uuid find qos" + " 'external-ids:vm-id=3D\"66616b65-7575-6= 964-0000-000000000000\"'" + " 'external-ids:ifname=3D\"fake-iface\"'\= n" + OVS_VSCTL " --timeout=3D5 set Interface fake-iface = ingress_policing_rate=3D0 ingress_policing_burst=3D0\n")); + return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 -VIR_TEST_MAIN(mymain); +VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virnetdevbandwidth")) --=20 2.30.2.windows.1