From nobody Sun Feb 8 10:48:37 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=1555521603; cv=none; d=zoho.com; s=zohoarc; b=SIt1kmUJcBGDPHaOdhMjaHI1Eng0Zx/wSSeGT5WW215k/VoIT4s2Fx43cGP3S4BC0Xvlk4z4XGk+nCIEd6WzAbZCY4od/Q8skW/wUqGskxrG26+n6JY5Xr5802RR7NgmGgMNbdNQTIekOwmArq4YC4aI+hYtopintolOma+Ri/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555521603; 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=WdljJBb2xWv318baYTPOBd38ev8d9AlIUdho+7f8Rms=; b=cp53wGPBl+Vc0qFhsLaNRdEsAsKkmqNTaRucLsCQfa6ekecSOxAmxtLDNK2m6k5eoGMdNEvqTdN++C1uq2C8MKQ7+yfu+r6GHJhPFn478Mohu/ey3sBXf5XadlqMp/mwAjCbdrqFlxSDS5hbJAOH4SZePEXwC5zfW3yDEda1GQs= 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 1555521603153357.201501341057; Wed, 17 Apr 2019 10:20:03 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 4380F300512C; Wed, 17 Apr 2019 17:20:01 +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 1548C60C6B; Wed, 17 Apr 2019 17:20:01 +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 C4DF43FB30; Wed, 17 Apr 2019 17:20:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3HHJgJO030519 for ; Wed, 17 Apr 2019 13:19:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 68EFD5D71B; Wed, 17 Apr 2019 17:19:42 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-35.ams2.redhat.com [10.36.112.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id B76BF5D704; Wed, 17 Apr 2019 17:19:40 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 17 Apr 2019 18:19:03 +0100 Message-Id: <20190417171929.9399-4-berrange@redhat.com> In-Reply-To: <20190417171929.9399-1-berrange@redhat.com> References: <20190417171929.9399-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Laine Stump Subject: [libvirt] [PATCH v4 03/29] conf: don't pass interface type into virNetDevBandwidthParse 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 17 Apr 2019 17:20:02 +0000 (UTC) The virNetDevBandwidthParse method uses the interface type to decide whether to allow use of the "floor" parameter. Using the interface type is not convenient as callers may not have that available, but still wish to allow use of "floor". Switch to an explicit boolean to control its usage. Reviewed-by: Laine Stump Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 4 ++-- src/conf/netdev_bandwidth_conf.c | 22 +++++++--------------- src/conf/netdev_bandwidth_conf.h | 2 +- src/conf/network_conf.c | 4 ++-- tests/virnetdevbandwidthtest.c | 2 +- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 51aa48f421..0df3c2ed49 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11270,7 +11270,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node, if (bandwidth_node && virNetDevBandwidthParse(&actual->bandwidth, bandwidth_node, - actual->type) < 0) + def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWO= RK) < 0) goto error; =20 vlanNode =3D virXPathNode("./vlan", ctxt); @@ -11609,7 +11609,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, } else if (virXMLNodeNameEqual(cur, "bandwidth")) { if (virNetDevBandwidthParse(&def->bandwidth, cur, - def->type) < 0) + def->type =3D=3D VIR_DOMAIN_NE= T_TYPE_NETWORK) < 0) goto error; } else if (virXMLNodeNameEqual(cur, "vlan")) { if (virNetDevVlanParse(cur, ctxt, &def->vlan) < 0) diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_c= onf.c index 3113cde888..014941836d 100644 --- a/src/conf/netdev_bandwidth_conf.c +++ b/src/conf/netdev_bandwidth_conf.c @@ -100,18 +100,18 @@ virNetDevBandwidthParseRate(xmlNodePtr node, virNetDe= vBandwidthRatePtr rate) * virNetDevBandwidthParse: * @bandwidth: parsed bandwidth * @node: XML node - * @net_type: one of virDomainNetType + * @allowFloor: whether "floor" setting is supported * * Parse bandwidth XML and return pointer to structure. - * @net_type tell to which type will/is interface connected to. - * Pass -1 if this is not called on interface. + * The @allowFloor attribute indicates whether the caller + * is able to support use of the "floor" setting. * * Returns !NULL on success, NULL on error. */ int virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth, xmlNodePtr node, - int net_type) + bool allowFloor) { int ret =3D -1; virNetDevBandwidthPtr def =3D NULL; @@ -162,17 +162,9 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwid= th, goto cleanup; } =20 - if (def->in->floor && net_type !=3D VIR_DOMAIN_NET_TYPE_NETWORK) { - if (net_type =3D=3D -1) { - /* 'floor' on network isn't supported */ - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("floor attribute isn't supported for " - "network's bandwidth yet")); - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("floor attribute is supported only for " - "interfaces of type network")); - } + if (def->in->floor && !allowFloor) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("floor attribute is not supported for this co= nfig")); goto cleanup; } } diff --git a/src/conf/netdev_bandwidth_conf.h b/src/conf/netdev_bandwidth_c= onf.h index cb1ffd29e0..7fe750ce27 100644 --- a/src/conf/netdev_bandwidth_conf.h +++ b/src/conf/netdev_bandwidth_conf.h @@ -27,7 +27,7 @@ =20 int virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth, xmlNodePtr node, - int net_type) + bool allowFloor) ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; int virNetDevBandwidthFormat(virNetDevBandwidthPtr def, virBufferPtr buf); diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 78bff6f687..91562de269 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, -1) < 0) + virNetDevBandwidthParse(&def->bandwidth, bandwidth_node, false) < = 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, -1) < 0) + virNetDevBandwidthParse(&def->bandwidth, bandwidthNode, false) < 0) goto error; =20 vlanNode =3D virXPathNode("./vlan", ctxt); diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c index 96776fa033..23788b4164 100644 --- a/tests/virnetdevbandwidthtest.c +++ b/tests/virnetdevbandwidthtest.c @@ -55,7 +55,7 @@ struct testSetStruct { \ rc =3D virNetDevBandwidthParse(&(var), \ ctxt->node, \ - VIR_DOMAIN_NET_TYPE_NETWORK); \ + true); \ xmlFreeDoc(doc); \ xmlXPathFreeContext(ctxt); \ if (rc < 0) \ --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list