From nobody Sun May 5 17:05:25 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 1635753192140218.7797031017434; Mon, 1 Nov 2021 00:53:12 -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-259-AR7lEx3CP0e___yDdboYBA-1; Mon, 01 Nov 2021 03:53:06 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EB9921006AA9; Mon, 1 Nov 2021 07:53:00 +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 AE80C60BF4; Mon, 1 Nov 2021 07:52:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B9FC91806D03; Mon, 1 Nov 2021 07:52:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A17qs5C018380 for ; Mon, 1 Nov 2021 03:52:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id C82E540CFD10; Mon, 1 Nov 2021 07:52:54 +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 C34A440CFD01 for ; Mon, 1 Nov 2021 07:52:54 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A8E081066681 for ; Mon, 1 Nov 2021 07:52:54 +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-395-CIQkm5pAOKGi9Mi806uOBQ-1; Mon, 01 Nov 2021 03:52:52 -0400 Received: from zhangjl0200.home.langchao.com (unknown [223.104.194.160]) by smtp2 (Coremail) with SMTP id DMmowACHbFTNnH9hj07dAw--.13707S3; Mon, 01 Nov 2021 15:52:49 +0800 (CST) X-MC-Unique: AR7lEx3CP0e___yDdboYBA-1 X-MC-Unique: CIQkm5pAOKGi9Mi806uOBQ-1 From: jx8zjs To: libvir-list@redhat.com Subject: [PATCH 1/1] virsh: inherit qos from network definition when attaching an interface Date: Mon, 1 Nov 2021 15:52:02 +0800 Message-Id: <20211101075202.1477-2-jx8zjs@126.com> In-Reply-To: <20211101075202.1477-1-jx8zjs@126.com> References: <20211101075202.1477-1-jx8zjs@126.com> MIME-Version: 1.0 X-CM-TRANSID: DMmowACHbFTNnH9hj07dAw--.13707S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxZF18ZF1xKr1kKFWDGr18uFg_yoW5Zr48pF n3K3ZxJ397XFn3Jr13Cr4FgF1rCw40ya17urs3Xw1DZFnrJw13Ww12yFWUuF1UArW3Zr1Y kFy5Gwn8GayUAaUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UoWl9UUUUU= X-Originating-IP: [223.104.194.160] X-CM-SenderInfo: dm0y6ybv6rjloofrz/1tbi5BE+SFpECFXeAQAAsf 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.84 on 10.11.54.1 X-loop: libvir-list@redhat.com Cc: shenjiatong@inspur.com, zhangjl02@inspur.com, jx8zjs 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.12 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: 1635753194422100001 Content-Type: text/plain; charset="utf-8" Fix bug 1826168: bridge type network with ovs bridge can start with Qos setting which do not take any effect Resolves:https://bugzilla.redhat.com/show_bug.cgi?id=3D1826168 Signed-off-by: jx8zjs --- tools/virsh-domain.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 7f3356a536..b809a0e30f 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -32,6 +32,7 @@ #include "virbitmap.h" #include "virbuffer.h" #include "conf/domain_conf.h" +#include "conf/network_conf.h" #include "viralloc.h" #include "vircommand.h" #include "virfile.h" @@ -907,6 +908,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *xml =3D NULL; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; + bool sourceQos =3D false; bool current =3D vshCommandOptBool(cmd, "current"); bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); @@ -971,6 +973,32 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) } } =20 + if (!inboundStr && !outboundStr) { + virNetworkPtr network =3D NULL; + virshControl *priv =3D ctl->privData; + g_autofree char *networkDump =3D NULL; + g_autoptr(virNetworkDef) netdef =3D NULL; + + network =3D virNetworkLookupByName(priv->conn, source); + + if (network) { + networkDump =3D virNetworkGetXMLDesc(network, VIR_NETWORK_XML_= INACTIVE); + netdef =3D virNetworkDefParseString(networkDump, NULL, false); + if (netdef->bandwidth) { + sourceQos =3D true; + memset(&inbound, 0, sizeof(inbound)); + inbound =3D *netdef->bandwidth->in; + memset(&outbound, 0, sizeof(outbound)); + outbound =3D *netdef->bandwidth->out; + } + } else { + vshDebug(ctl, VSH_ERR_DEBUG, "failed to get network '%s'", sou= rce); + } + + virObjectUnref(network); + virObjectUnref(priv); + } + /* Make XML of interface */ virBufferAsprintf(&buf, "\n", alias); =20 - if (inboundStr || outboundStr) { + if (inboundStr || outboundStr || sourceQos) { virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); - if (inboundStr && (inbound.average || inbound.floor)) { + if ((inboundStr || sourceQos) && (inbound.average || inbound.floor= )) { virBufferAddLit(&buf, " 0) virBufferAsprintf(&buf, " average=3D'%llu'", inbound.avera= ge); @@ -1060,7 +1088,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) virBufferAsprintf(&buf, " floor=3D'%llu'", inbound.floor); virBufferAddLit(&buf, "/>\n"); } - if (outboundStr && outbound.average > 0) { + if ((outboundStr || sourceQos) && outbound.average > 0) { virBufferAsprintf(&buf, " 0) virBufferAsprintf(&buf, " peak=3D'%llu'", outbound.peak); --=20 2.30.2.windows.1