if (bandwidth_node &&
virNetDevBandwidthParse(&actual->bandwidth,
bandwidth_node,
- actual->type) < 0)
+ actual->type == VIR_DOMAIN_NET_TYPE_NETWORK) < 0)
goto error;
vlanNode = virXPathNode("./vlan", ctxt);
} else if (virXMLNodeNameEqual(cur, "bandwidth")) {
if (virNetDevBandwidthParse(&def->bandwidth,
cur,
- def->type) < 0)
+ def->type == VIR_DOMAIN_NET_TYPE_NETWORK) < 0)
goto error;
} else if (virXMLNodeNameEqual(cur, "vlan")) {
if (virNetDevVlanParse(cur, ctxt, &def->vlan) < 0)
* 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 = -1;
virNetDevBandwidthPtr def = NULL;
goto cleanup;
}
- if (def->in->floor && net_type != VIR_DOMAIN_NET_TYPE_NETWORK) {
- if (net_type == -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 config"));
goto cleanup;
}
}
int virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
xmlNodePtr node,
- int net_type)
+ bool allowFloor)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virNetDevBandwidthFormat(virNetDevBandwidthPtr def,
virBufferPtr buf);
bandwidth_node = virXPathNode("./bandwidth", ctxt);
if (bandwidth_node &&
- virNetDevBandwidthParse(&def->bandwidth, bandwidth_node, -1) < 0)
+ virNetDevBandwidthParse(&def->bandwidth, bandwidth_node, false) < 0)
goto cleanup;
vlanNode = virXPathNode("./vlan", ctxt);
}
if ((bandwidthNode = virXPathNode("./bandwidth", ctxt)) &&
- virNetDevBandwidthParse(&def->bandwidth, bandwidthNode, -1) < 0)
+ virNetDevBandwidthParse(&def->bandwidth, bandwidthNode, false) < 0)
goto error;
vlanNode = virXPathNode("./vlan", ctxt);
\
rc = virNetDevBandwidthParse(&(var), \
ctxt->node, \
- VIR_DOMAIN_NET_TYPE_NETWORK); \
+ true); \
xmlFreeDoc(doc); \
xmlXPathFreeContext(ctxt); \
if (rc < 0) \