mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
network: Alter virNetworkObj @class_id to be @classIdMap
Change the variable name to be a bit more descriptive and less confusing when used with the data.network.actual->class_id. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
8489d31cee
commit
d5d699ec18
@ -79,13 +79,13 @@ virNetworkObjNew(void)
|
||||
if (!(net = virObjectLockableNew(virNetworkObjClass)))
|
||||
return NULL;
|
||||
|
||||
if (!(net->class_id = virBitmapNew(CLASS_ID_BITMAP_SIZE)))
|
||||
if (!(net->classIdMap = virBitmapNew(CLASS_ID_BITMAP_SIZE)))
|
||||
goto error;
|
||||
|
||||
/* The first three class IDs are already taken */
|
||||
ignore_value(virBitmapSetBit(net->class_id, 0));
|
||||
ignore_value(virBitmapSetBit(net->class_id, 1));
|
||||
ignore_value(virBitmapSetBit(net->class_id, 2));
|
||||
ignore_value(virBitmapSetBit(net->classIdMap, 0));
|
||||
ignore_value(virBitmapSetBit(net->classIdMap, 1));
|
||||
ignore_value(virBitmapSetBit(net->classIdMap, 2));
|
||||
|
||||
return net;
|
||||
|
||||
@ -358,7 +358,7 @@ virNetworkObjDispose(void *obj)
|
||||
|
||||
virNetworkDefFree(net->def);
|
||||
virNetworkDefFree(net->newDef);
|
||||
virBitmapFree(net->class_id);
|
||||
virBitmapFree(net->classIdMap);
|
||||
virObjectUnref(net->macmap);
|
||||
}
|
||||
|
||||
@ -698,17 +698,17 @@ virNetworkObjFormat(virNetworkObjPtr net,
|
||||
unsigned int flags)
|
||||
{
|
||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||
char *class_id = virBitmapFormat(net->class_id);
|
||||
char *classIdStr = virBitmapFormat(net->classIdMap);
|
||||
size_t i;
|
||||
|
||||
if (!class_id)
|
||||
if (!classIdStr)
|
||||
goto error;
|
||||
|
||||
virBufferAddLit(&buf, "<networkstatus>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
virBufferAsprintf(&buf, "<class_id bitmap='%s'/>\n", class_id);
|
||||
virBufferAsprintf(&buf, "<class_id bitmap='%s'/>\n", classIdStr);
|
||||
virBufferAsprintf(&buf, "<floor sum='%llu'/>\n", net->floor_sum);
|
||||
VIR_FREE(class_id);
|
||||
VIR_FREE(classIdStr);
|
||||
|
||||
for (i = 0; i < VIR_NETWORK_TAINT_LAST; i++) {
|
||||
if (net->taint & (1 << i))
|
||||
@ -765,7 +765,7 @@ virNetworkLoadState(virNetworkObjListPtr nets,
|
||||
xmlDocPtr xml = NULL;
|
||||
xmlNodePtr node = NULL, *nodes = NULL;
|
||||
xmlXPathContextPtr ctxt = NULL;
|
||||
virBitmapPtr class_id_map = NULL;
|
||||
virBitmapPtr classIdMap = NULL;
|
||||
unsigned long long floor_sum_val = 0;
|
||||
unsigned int taint = 0;
|
||||
int n;
|
||||
@ -802,18 +802,19 @@ virNetworkLoadState(virNetworkObjListPtr nets,
|
||||
if (virXMLNodeNameEqual(node, "networkstatus")) {
|
||||
/* Newer network status file. Contains useful
|
||||
* info which are not to be found in bare config XML */
|
||||
char *class_id = NULL;
|
||||
char *classIdStr = NULL;
|
||||
char *floor_sum = NULL;
|
||||
|
||||
ctxt->node = node;
|
||||
if ((class_id = virXPathString("string(./class_id[1]/@bitmap)", ctxt))) {
|
||||
if (virBitmapParse(class_id, &class_id_map,
|
||||
if ((classIdStr = virXPathString("string(./class_id[1]/@bitmap)",
|
||||
ctxt))) {
|
||||
if (virBitmapParse(classIdStr, &classIdMap,
|
||||
CLASS_ID_BITMAP_SIZE) < 0) {
|
||||
VIR_FREE(class_id);
|
||||
VIR_FREE(classIdStr);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
VIR_FREE(class_id);
|
||||
VIR_FREE(classIdStr);
|
||||
|
||||
floor_sum = virXPathString("string(./floor[1]/@sum)", ctxt);
|
||||
if (floor_sum &&
|
||||
@ -855,9 +856,9 @@ virNetworkLoadState(virNetworkObjListPtr nets,
|
||||
/* do not put any "goto error" below this comment */
|
||||
|
||||
/* assign status data stored in the network object */
|
||||
if (class_id_map) {
|
||||
virBitmapFree(net->class_id);
|
||||
net->class_id = class_id_map;
|
||||
if (classIdMap) {
|
||||
virBitmapFree(net->classIdMap);
|
||||
net->classIdMap = classIdMap;
|
||||
}
|
||||
|
||||
if (floor_sum_val > 0)
|
||||
@ -874,7 +875,7 @@ virNetworkLoadState(virNetworkObjListPtr nets,
|
||||
|
||||
error:
|
||||
VIR_FREE(nodes);
|
||||
virBitmapFree(class_id_map);
|
||||
virBitmapFree(classIdMap);
|
||||
virNetworkDefFree(def);
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ struct _virNetworkObj {
|
||||
virNetworkDefPtr def; /* The current definition */
|
||||
virNetworkDefPtr newDef; /* New definition to activate at shutdown */
|
||||
|
||||
virBitmapPtr class_id; /* bitmap of class IDs for QoS */
|
||||
virBitmapPtr classIdMap; /* bitmap of class IDs for QoS */
|
||||
unsigned long long floor_sum; /* sum of all 'floor'-s of attached NICs */
|
||||
|
||||
unsigned int taint;
|
||||
|
@ -5347,9 +5347,9 @@ networkNextClassID(virNetworkObjPtr obj)
|
||||
{
|
||||
ssize_t ret = 0;
|
||||
|
||||
ret = virBitmapNextClearBit(obj->class_id, -1);
|
||||
ret = virBitmapNextClearBit(obj->classIdMap, -1);
|
||||
|
||||
if (ret < 0 || virBitmapSetBit(obj->class_id, ret) < 0)
|
||||
if (ret < 0 || virBitmapSetBit(obj->classIdMap, ret) < 0)
|
||||
return -1;
|
||||
|
||||
return ret;
|
||||
@ -5387,7 +5387,7 @@ networkPlugBandwidthImpl(virNetworkObjPtr obj,
|
||||
obj->floor_sum += ifaceBand->in->floor;
|
||||
/* update status file */
|
||||
if (virNetworkObjSaveStatus(driver->stateDir, obj) < 0) {
|
||||
ignore_value(virBitmapClearBit(obj->class_id, class_id));
|
||||
ignore_value(virBitmapClearBit(obj->classIdMap, class_id));
|
||||
obj->floor_sum -= ifaceBand->in->floor;
|
||||
iface->data.network.actual->class_id = 0;
|
||||
ignore_value(virNetDevBandwidthUnplug(obj->def->bridge, class_id));
|
||||
@ -5476,12 +5476,12 @@ networkUnplugBandwidth(virNetworkObjPtr obj,
|
||||
/* update sum of 'floor'-s of attached NICs */
|
||||
obj->floor_sum -= ifaceBand->in->floor;
|
||||
/* return class ID */
|
||||
ignore_value(virBitmapClearBit(obj->class_id,
|
||||
ignore_value(virBitmapClearBit(obj->classIdMap,
|
||||
iface->data.network.actual->class_id));
|
||||
/* update status file */
|
||||
if (virNetworkObjSaveStatus(driver->stateDir, obj) < 0) {
|
||||
obj->floor_sum += ifaceBand->in->floor;
|
||||
ignore_value(virBitmapSetBit(obj->class_id,
|
||||
ignore_value(virBitmapSetBit(obj->classIdMap,
|
||||
iface->data.network.actual->class_id));
|
||||
goto cleanup;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user