bandwidth_node = virXPathNode("./bandwidth", ctxt);
if (bandwidth_node &&
virNetDevBandwidthParse(&actual->bandwidth,
+ NULL,
bandwidth_node,
actual->type == VIR_DOMAIN_NET_TYPE_NETWORK) < 0)
goto error;
}
} else if (virXMLNodeNameEqual(cur, "bandwidth")) {
if (virNetDevBandwidthParse(&def->bandwidth,
+ NULL,
cur,
def->type == VIR_DOMAIN_NET_TYPE_NETWORK) < 0)
goto error;
return -1;
if (virNetDevVPortProfileFormat(virDomainNetGetActualVirtPortProfile(def), buf) < 0)
return -1;
- if (virNetDevBandwidthFormat(virDomainNetGetActualBandwidth(def), buf) < 0)
+ if (virNetDevBandwidthFormat(virDomainNetGetActualBandwidth(def), 0, buf) < 0)
return -1;
return 0;
}
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;
/* ONLY for internal status storage - format the ActualNetDef
/**
* virNetDevBandwidthParse:
* @bandwidth: parsed bandwidth
+ * @class_id: parsed class ID
* @node: XML node
* @allowFloor: whether "floor" setting is supported
*
*/
int
virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
+ unsigned int *class_id,
xmlNodePtr node,
bool allowFloor)
{
virNetDevBandwidthPtr def = NULL;
xmlNodePtr cur;
xmlNodePtr in = NULL, out = NULL;
+ char *class_id_prop = NULL;
if (VIR_ALLOC(def) < 0)
return ret;
goto cleanup;
}
+ class_id_prop = virXMLPropString(node, "classID");
+ if (class_id_prop) {
+ if (!class_id) {
+ virReportError(VIR_ERR_XML_DETAIL, "%s",
+ _("classID attribute not supported on <bandwidth> "
+ "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 = node->children;
while (cur) {
ret = 0;
cleanup:
+ VIR_FREE(class_id_prop);
virNetDevBandwidthFree(def);
return ret;
}
/**
* 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.
* Returns 0 on success, else -1.
*/
int
-virNetDevBandwidthFormat(virNetDevBandwidthPtr def, virBufferPtr buf)
+virNetDevBandwidthFormat(virNetDevBandwidthPtr def,
+ unsigned int class_id,
+ virBufferPtr buf)
{
int ret = -1;
goto cleanup;
}
- virBufferAddLit(buf, "<bandwidth>\n");
+ virBufferAddLit(buf, "<bandwidth");
+ if (class_id)
+ virBufferAsprintf(buf, " classID='%u'", class_id);
+ virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
if (virNetDevBandwidthRateFormat(def->in, buf, "inbound") < 0 ||
virNetDevBandwidthRateFormat(def->out, buf, "outbound") < 0)
#include "domain_conf.h"
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);
void virDomainClearNetBandwidth(virDomainObjPtr vm)
bandwidth_node = virXPathNode("./bandwidth", ctxt);
if (bandwidth_node &&
- virNetDevBandwidthParse(&def->bandwidth, bandwidth_node, false) < 0)
+ virNetDevBandwidthParse(&def->bandwidth, NULL, bandwidth_node, false) < 0)
goto cleanup;
vlanNode = virXPathNode("./vlan", ctxt);
}
if ((bandwidthNode = virXPathNode("./bandwidth", ctxt)) &&
- virNetDevBandwidthParse(&def->bandwidth, bandwidthNode, false) < 0)
+ virNetDevBandwidthParse(&def->bandwidth, NULL, bandwidthNode, false) < 0)
goto error;
vlanNode = virXPathNode("./vlan", ctxt);
return -1;
if (virNetDevVPortProfileFormat(def->virtPortProfile, buf) < 0)
return -1;
- virNetDevBandwidthFormat(def->bandwidth, buf);
+ virNetDevBandwidthFormat(def->bandwidth, 0, buf);
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</portgroup>\n");
return 0;
if (virNetDevVlanFormat(&def->vlan, buf) < 0)
goto error;
- if (virNetDevBandwidthFormat(def->bandwidth, buf) < 0)
+ if (virNetDevBandwidthFormat(def->bandwidth, 0, buf) < 0)
goto error;
for (i = 0; i < def->nips; i++) {
goto cleanup; \
\
rc = virNetDevBandwidthParse(&(var), \
+ NULL, \
ctxt->node, \
true); \
xmlFreeDoc(doc); \