From nobody Sat Feb 7 15:30:15 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1558625631; cv=none; d=zoho.com; s=zohoarc; b=a/CkcxNVmaqz9Xv7uAVwyXLTrDXnYNVSJdSZejXG+T2a7ZGKOuvgP/XFKb+IMzYN+1tOLZhlOc8hZmnzX0ZLh0FzZvRqWHMUdjgSXiKT4mAz8G12yzZCN1K47MW4/XnoJh4lyf7lH/AgwCPfWtzQgOl+1qeWvi/WSiIu5o+EvWg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558625631; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=1gFPFs/z9Sl6/d3TdULPCps8nIJHmK8wAzTGVsKyQ5c=; b=Ncdc6msGO1aakmhVzHzV0w0BRC67HiQP5qZyaMCpAy4neNNikKul9zBswoem7+zABfTggg21asOMWu+ydDdGGPFcLu4DOkx5krDtzs2g2cUZsakX0R6FqdkgRrvq9V5sfeufOtPmOhG8af2vr5hgv2XUyOoW7NHbQN2R5X3jqg8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1558625631684887.9898769166675; Thu, 23 May 2019 08:33:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5DF1C19CF89; Thu, 23 May 2019 15:33:25 +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 E1B7D7BE75; Thu, 23 May 2019 15:33:17 +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 4DFE71806B14; Thu, 23 May 2019 15:33:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x4NFXBgT006501 for ; Thu, 23 May 2019 11:33:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 68F6E7BE72; Thu, 23 May 2019 15:33:11 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-64.ams2.redhat.com [10.36.112.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6866D620CA; Thu, 23 May 2019 15:33:08 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 23 May 2019 16:32:40 +0100 Message-Id: <20190523153302.28526-2-berrange@redhat.com> In-Reply-To: <20190523153302.28526-1-berrange@redhat.com> References: <20190523153302.28526-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Laine Stump Subject: [libvirt] [PATCH v6 01/23] conf: allow bandwidth parsing / formatting to include class ID 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 23 May 2019 15:33:50 +0000 (UTC) The domain conf actual network def stores a element separately from the . The class ID should really just be an attribute on the element. We can't change existing XML, and this isn't visible to users since it is internal XML only. When we expose the new network port XML to users though, we should get the design right. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Laine Stump --- src/conf/domain_conf.c | 6 ++++-- src/conf/netdev_bandwidth_conf.c | 30 ++++++++++++++++++++++++++++-- src/conf/netdev_bandwidth_conf.h | 2 ++ src/conf/network_conf.c | 8 ++++---- tests/virnetdevbandwidthtest.c | 1 + 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 926c2139b7..440a75ec1d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11278,6 +11278,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node, bandwidth_node =3D virXPathNode("./bandwidth", ctxt); if (bandwidth_node && virNetDevBandwidthParse(&actual->bandwidth, + NULL, bandwidth_node, actual->type =3D=3D VIR_DOMAIN_NET_TYPE_NE= TWORK) < 0) goto error; @@ -11617,6 +11618,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, } } else if (virXMLNodeNameEqual(cur, "bandwidth")) { if (virNetDevBandwidthParse(&def->bandwidth, + NULL, cur, def->type =3D=3D VIR_DOMAIN_NE= T_TYPE_NETWORK) < 0) goto error; @@ -25014,7 +25016,7 @@ virDomainActualNetDefContentsFormat(virBufferPtr bu= f, return -1; if (virNetDevVPortProfileFormat(virDomainNetGetActualVirtPortProfile(d= ef), buf) < 0) return -1; - if (virNetDevBandwidthFormat(virDomainNetGetActualBandwidth(def), buf)= < 0) + if (virNetDevBandwidthFormat(virDomainNetGetActualBandwidth(def), 0, b= uf) < 0) return -1; return 0; } @@ -25391,7 +25393,7 @@ virDomainNetDefFormat(virBufferPtr buf, return -1; if (virNetDevVPortProfileFormat(def->virtPortProfile, buf) < 0) return -1; - if (virNetDevBandwidthFormat(def->bandwidth, buf) < 0) + if (virNetDevBandwidthFormat(def->bandwidth, 0, buf) < 0) return -1; =20 /* ONLY for internal status storage - format the ActualNetDef diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_c= onf.c index 014941836d..9af2173b7b 100644 --- a/src/conf/netdev_bandwidth_conf.c +++ b/src/conf/netdev_bandwidth_conf.c @@ -99,6 +99,7 @@ virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevBan= dwidthRatePtr rate) /** * virNetDevBandwidthParse: * @bandwidth: parsed bandwidth + * @class_id: parsed class ID * @node: XML node * @allowFloor: whether "floor" setting is supported * @@ -110,6 +111,7 @@ virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevB= andwidthRatePtr rate) */ int virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth, + unsigned int *class_id, xmlNodePtr node, bool allowFloor) { @@ -117,6 +119,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidt= h, virNetDevBandwidthPtr def =3D NULL; xmlNodePtr cur; xmlNodePtr in =3D NULL, out =3D NULL; + char *class_id_prop =3D NULL; =20 if (VIR_ALLOC(def) < 0) return ret; @@ -127,6 +130,22 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwid= th, goto cleanup; } =20 + class_id_prop =3D virXMLPropString(node, "classID"); + if (class_id_prop) { + if (!class_id) { + virReportError(VIR_ERR_XML_DETAIL, "%s", + _("classID attribute not supported on " + "in this usage context")); + goto cleanup; + } + if (virStrToLong_ui(class_id_prop, NULL, 10, class_id) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to parse class id '%s'"), + class_id_prop); + goto cleanup; + } + } + cur =3D node->children; =20 while (cur) { @@ -194,6 +213,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidt= h, ret =3D 0; =20 cleanup: + VIR_FREE(class_id_prop); virNetDevBandwidthFree(def); return ret; } @@ -231,6 +251,7 @@ virNetDevBandwidthRateFormat(virNetDevBandwidthRatePtr = def, /** * virNetDevBandwidthFormat: * @def: Data source + * @class_id: the class ID to format, 0 to skip * @buf: Buffer to print to * * Formats bandwidth and prepend each line with @indent. @@ -239,7 +260,9 @@ virNetDevBandwidthRateFormat(virNetDevBandwidthRatePtr = def, * Returns 0 on success, else -1. */ int -virNetDevBandwidthFormat(virNetDevBandwidthPtr def, virBufferPtr buf) +virNetDevBandwidthFormat(virNetDevBandwidthPtr def, + unsigned int class_id, + virBufferPtr buf) { int ret =3D -1; =20 @@ -251,7 +274,10 @@ virNetDevBandwidthFormat(virNetDevBandwidthPtr def, vi= rBufferPtr buf) goto cleanup; } =20 - virBufferAddLit(buf, "\n"); + virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); if (virNetDevBandwidthRateFormat(def->in, buf, "inbound") < 0 || virNetDevBandwidthRateFormat(def->out, buf, "outbound") < 0) diff --git a/src/conf/netdev_bandwidth_conf.h b/src/conf/netdev_bandwidth_c= onf.h index 7fe750ce27..b91222321a 100644 --- a/src/conf/netdev_bandwidth_conf.h +++ b/src/conf/netdev_bandwidth_conf.h @@ -26,10 +26,12 @@ # include "domain_conf.h" =20 int virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth, + unsigned int *class_id, xmlNodePtr node, bool allowFloor) ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; int virNetDevBandwidthFormat(virNetDevBandwidthPtr def, + unsigned int class_id, virBufferPtr buf); =20 void virDomainClearNetBandwidth(virDomainObjPtr vm) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 91562de269..09e379ae9a 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1188,7 +1188,7 @@ virNetworkPortGroupParseXML(virPortGroupDefPtr def, =20 bandwidth_node =3D virXPathNode("./bandwidth", ctxt); if (bandwidth_node && - virNetDevBandwidthParse(&def->bandwidth, bandwidth_node, false) < = 0) + virNetDevBandwidthParse(&def->bandwidth, NULL, bandwidth_node, fal= se) < 0) goto cleanup; =20 vlanNode =3D virXPathNode("./vlan", ctxt); @@ -1682,7 +1682,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) } =20 if ((bandwidthNode =3D virXPathNode("./bandwidth", ctxt)) && - virNetDevBandwidthParse(&def->bandwidth, bandwidthNode, false) < 0) + virNetDevBandwidthParse(&def->bandwidth, NULL, bandwidthNode, fals= e) < 0) goto error; =20 vlanNode =3D virXPathNode("./vlan", ctxt); @@ -2311,7 +2311,7 @@ virPortGroupDefFormat(virBufferPtr buf, return -1; if (virNetDevVPortProfileFormat(def->virtPortProfile, buf) < 0) return -1; - virNetDevBandwidthFormat(def->bandwidth, buf); + virNetDevBandwidthFormat(def->bandwidth, 0, buf); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); return 0; @@ -2566,7 +2566,7 @@ virNetworkDefFormatBuf(virBufferPtr buf, =20 if (virNetDevVlanFormat(&def->vlan, buf) < 0) goto error; - if (virNetDevBandwidthFormat(def->bandwidth, buf) < 0) + if (virNetDevBandwidthFormat(def->bandwidth, 0, buf) < 0) goto error; =20 for (i =3D 0; i < def->nips; i++) { diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c index 23788b4164..2c0b6a6713 100644 --- a/tests/virnetdevbandwidthtest.c +++ b/tests/virnetdevbandwidthtest.c @@ -54,6 +54,7 @@ struct testSetStruct { goto cleanup; \ \ rc =3D virNetDevBandwidthParse(&(var), \ + NULL, \ ctxt->node, \ true); \ xmlFreeDoc(doc); \ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list