mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
conf: don't pass interface type into virNetDevBandwidthParse
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 <laine@laine.org> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
9900da3c93
commit
e2c5f0f6cf
@ -11270,7 +11270,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node,
|
|||||||
if (bandwidth_node &&
|
if (bandwidth_node &&
|
||||||
virNetDevBandwidthParse(&actual->bandwidth,
|
virNetDevBandwidthParse(&actual->bandwidth,
|
||||||
bandwidth_node,
|
bandwidth_node,
|
||||||
actual->type) < 0)
|
actual->type == VIR_DOMAIN_NET_TYPE_NETWORK) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
vlanNode = virXPathNode("./vlan", ctxt);
|
vlanNode = virXPathNode("./vlan", ctxt);
|
||||||
@ -11609,7 +11609,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
} else if (virXMLNodeNameEqual(cur, "bandwidth")) {
|
} else if (virXMLNodeNameEqual(cur, "bandwidth")) {
|
||||||
if (virNetDevBandwidthParse(&def->bandwidth,
|
if (virNetDevBandwidthParse(&def->bandwidth,
|
||||||
cur,
|
cur,
|
||||||
def->type) < 0)
|
def->type == VIR_DOMAIN_NET_TYPE_NETWORK) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
} else if (virXMLNodeNameEqual(cur, "vlan")) {
|
} else if (virXMLNodeNameEqual(cur, "vlan")) {
|
||||||
if (virNetDevVlanParse(cur, ctxt, &def->vlan) < 0)
|
if (virNetDevVlanParse(cur, ctxt, &def->vlan) < 0)
|
||||||
|
@ -100,18 +100,18 @@ virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevBandwidthRatePtr rate)
|
|||||||
* virNetDevBandwidthParse:
|
* virNetDevBandwidthParse:
|
||||||
* @bandwidth: parsed bandwidth
|
* @bandwidth: parsed bandwidth
|
||||||
* @node: XML node
|
* @node: XML node
|
||||||
* @net_type: one of virDomainNetType
|
* @allowFloor: whether "floor" setting is supported
|
||||||
*
|
*
|
||||||
* Parse bandwidth XML and return pointer to structure.
|
* Parse bandwidth XML and return pointer to structure.
|
||||||
* @net_type tell to which type will/is interface connected to.
|
* The @allowFloor attribute indicates whether the caller
|
||||||
* Pass -1 if this is not called on interface.
|
* is able to support use of the "floor" setting.
|
||||||
*
|
*
|
||||||
* Returns !NULL on success, NULL on error.
|
* Returns !NULL on success, NULL on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
|
virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
|
||||||
xmlNodePtr node,
|
xmlNodePtr node,
|
||||||
int net_type)
|
bool allowFloor)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virNetDevBandwidthPtr def = NULL;
|
virNetDevBandwidthPtr def = NULL;
|
||||||
@ -162,17 +162,9 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->in->floor && net_type != VIR_DOMAIN_NET_TYPE_NETWORK) {
|
if (def->in->floor && !allowFloor) {
|
||||||
if (net_type == -1) {
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
/* 'floor' on network isn't supported */
|
_("floor attribute is not supported for this config"));
|
||||||
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"));
|
|
||||||
}
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
int virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
|
int virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
|
||||||
xmlNodePtr node,
|
xmlNodePtr node,
|
||||||
int net_type)
|
bool allowFloor)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
||||||
int virNetDevBandwidthFormat(virNetDevBandwidthPtr def,
|
int virNetDevBandwidthFormat(virNetDevBandwidthPtr def,
|
||||||
virBufferPtr buf);
|
virBufferPtr buf);
|
||||||
|
@ -1188,7 +1188,7 @@ virNetworkPortGroupParseXML(virPortGroupDefPtr def,
|
|||||||
|
|
||||||
bandwidth_node = virXPathNode("./bandwidth", ctxt);
|
bandwidth_node = virXPathNode("./bandwidth", ctxt);
|
||||||
if (bandwidth_node &&
|
if (bandwidth_node &&
|
||||||
virNetDevBandwidthParse(&def->bandwidth, bandwidth_node, -1) < 0)
|
virNetDevBandwidthParse(&def->bandwidth, bandwidth_node, false) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
vlanNode = virXPathNode("./vlan", ctxt);
|
vlanNode = virXPathNode("./vlan", ctxt);
|
||||||
@ -1682,7 +1682,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((bandwidthNode = virXPathNode("./bandwidth", ctxt)) &&
|
if ((bandwidthNode = virXPathNode("./bandwidth", ctxt)) &&
|
||||||
virNetDevBandwidthParse(&def->bandwidth, bandwidthNode, -1) < 0)
|
virNetDevBandwidthParse(&def->bandwidth, bandwidthNode, false) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
vlanNode = virXPathNode("./vlan", ctxt);
|
vlanNode = virXPathNode("./vlan", ctxt);
|
||||||
|
@ -55,7 +55,7 @@ struct testSetStruct {
|
|||||||
\
|
\
|
||||||
rc = virNetDevBandwidthParse(&(var), \
|
rc = virNetDevBandwidthParse(&(var), \
|
||||||
ctxt->node, \
|
ctxt->node, \
|
||||||
VIR_DOMAIN_NET_TYPE_NETWORK); \
|
true); \
|
||||||
xmlFreeDoc(doc); \
|
xmlFreeDoc(doc); \
|
||||||
xmlXPathFreeContext(ctxt); \
|
xmlXPathFreeContext(ctxt); \
|
||||||
if (rc < 0) \
|
if (rc < 0) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user