提交 d5d699ec 编写于 作者: J John Ferlan

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: NJohn Ferlan <jferlan@redhat.com>
上级 8489d31c
...@@ -79,13 +79,13 @@ virNetworkObjNew(void) ...@@ -79,13 +79,13 @@ virNetworkObjNew(void)
if (!(net = virObjectLockableNew(virNetworkObjClass))) if (!(net = virObjectLockableNew(virNetworkObjClass)))
return NULL; return NULL;
if (!(net->class_id = virBitmapNew(CLASS_ID_BITMAP_SIZE))) if (!(net->classIdMap = virBitmapNew(CLASS_ID_BITMAP_SIZE)))
goto error; goto error;
/* The first three class IDs are already taken */ /* The first three class IDs are already taken */
ignore_value(virBitmapSetBit(net->class_id, 0)); ignore_value(virBitmapSetBit(net->classIdMap, 0));
ignore_value(virBitmapSetBit(net->class_id, 1)); ignore_value(virBitmapSetBit(net->classIdMap, 1));
ignore_value(virBitmapSetBit(net->class_id, 2)); ignore_value(virBitmapSetBit(net->classIdMap, 2));
return net; return net;
...@@ -358,7 +358,7 @@ virNetworkObjDispose(void *obj) ...@@ -358,7 +358,7 @@ virNetworkObjDispose(void *obj)
virNetworkDefFree(net->def); virNetworkDefFree(net->def);
virNetworkDefFree(net->newDef); virNetworkDefFree(net->newDef);
virBitmapFree(net->class_id); virBitmapFree(net->classIdMap);
virObjectUnref(net->macmap); virObjectUnref(net->macmap);
} }
...@@ -698,17 +698,17 @@ virNetworkObjFormat(virNetworkObjPtr net, ...@@ -698,17 +698,17 @@ virNetworkObjFormat(virNetworkObjPtr net,
unsigned int flags) unsigned int flags)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
char *class_id = virBitmapFormat(net->class_id); char *classIdStr = virBitmapFormat(net->classIdMap);
size_t i; size_t i;
if (!class_id) if (!classIdStr)
goto error; goto error;
virBufferAddLit(&buf, "<networkstatus>\n"); virBufferAddLit(&buf, "<networkstatus>\n");
virBufferAdjustIndent(&buf, 2); 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); 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++) { for (i = 0; i < VIR_NETWORK_TAINT_LAST; i++) {
if (net->taint & (1 << i)) if (net->taint & (1 << i))
...@@ -765,7 +765,7 @@ virNetworkLoadState(virNetworkObjListPtr nets, ...@@ -765,7 +765,7 @@ virNetworkLoadState(virNetworkObjListPtr nets,
xmlDocPtr xml = NULL; xmlDocPtr xml = NULL;
xmlNodePtr node = NULL, *nodes = NULL; xmlNodePtr node = NULL, *nodes = NULL;
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
virBitmapPtr class_id_map = NULL; virBitmapPtr classIdMap = NULL;
unsigned long long floor_sum_val = 0; unsigned long long floor_sum_val = 0;
unsigned int taint = 0; unsigned int taint = 0;
int n; int n;
...@@ -802,18 +802,19 @@ virNetworkLoadState(virNetworkObjListPtr nets, ...@@ -802,18 +802,19 @@ virNetworkLoadState(virNetworkObjListPtr nets,
if (virXMLNodeNameEqual(node, "networkstatus")) { if (virXMLNodeNameEqual(node, "networkstatus")) {
/* Newer network status file. Contains useful /* Newer network status file. Contains useful
* info which are not to be found in bare config XML */ * info which are not to be found in bare config XML */
char *class_id = NULL; char *classIdStr = NULL;
char *floor_sum = NULL; char *floor_sum = NULL;
ctxt->node = node; ctxt->node = node;
if ((class_id = virXPathString("string(./class_id[1]/@bitmap)", ctxt))) { if ((classIdStr = virXPathString("string(./class_id[1]/@bitmap)",
if (virBitmapParse(class_id, &class_id_map, ctxt))) {
if (virBitmapParse(classIdStr, &classIdMap,
CLASS_ID_BITMAP_SIZE) < 0) { CLASS_ID_BITMAP_SIZE) < 0) {
VIR_FREE(class_id); VIR_FREE(classIdStr);
goto error; goto error;
} }
} }
VIR_FREE(class_id); VIR_FREE(classIdStr);
floor_sum = virXPathString("string(./floor[1]/@sum)", ctxt); floor_sum = virXPathString("string(./floor[1]/@sum)", ctxt);
if (floor_sum && if (floor_sum &&
...@@ -855,9 +856,9 @@ virNetworkLoadState(virNetworkObjListPtr nets, ...@@ -855,9 +856,9 @@ virNetworkLoadState(virNetworkObjListPtr nets,
/* do not put any "goto error" below this comment */ /* do not put any "goto error" below this comment */
/* assign status data stored in the network object */ /* assign status data stored in the network object */
if (class_id_map) { if (classIdMap) {
virBitmapFree(net->class_id); virBitmapFree(net->classIdMap);
net->class_id = class_id_map; net->classIdMap = classIdMap;
} }
if (floor_sum_val > 0) if (floor_sum_val > 0)
...@@ -874,7 +875,7 @@ virNetworkLoadState(virNetworkObjListPtr nets, ...@@ -874,7 +875,7 @@ virNetworkLoadState(virNetworkObjListPtr nets,
error: error:
VIR_FREE(nodes); VIR_FREE(nodes);
virBitmapFree(class_id_map); virBitmapFree(classIdMap);
virNetworkDefFree(def); virNetworkDefFree(def);
goto cleanup; goto cleanup;
} }
......
...@@ -38,7 +38,7 @@ struct _virNetworkObj { ...@@ -38,7 +38,7 @@ struct _virNetworkObj {
virNetworkDefPtr def; /* The current definition */ virNetworkDefPtr def; /* The current definition */
virNetworkDefPtr newDef; /* New definition to activate at shutdown */ 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 long long floor_sum; /* sum of all 'floor'-s of attached NICs */
unsigned int taint; unsigned int taint;
......
...@@ -5347,9 +5347,9 @@ networkNextClassID(virNetworkObjPtr obj) ...@@ -5347,9 +5347,9 @@ networkNextClassID(virNetworkObjPtr obj)
{ {
ssize_t ret = 0; 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 -1;
return ret; return ret;
...@@ -5387,7 +5387,7 @@ networkPlugBandwidthImpl(virNetworkObjPtr obj, ...@@ -5387,7 +5387,7 @@ networkPlugBandwidthImpl(virNetworkObjPtr obj,
obj->floor_sum += ifaceBand->in->floor; obj->floor_sum += ifaceBand->in->floor;
/* update status file */ /* update status file */
if (virNetworkObjSaveStatus(driver->stateDir, obj) < 0) { 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; obj->floor_sum -= ifaceBand->in->floor;
iface->data.network.actual->class_id = 0; iface->data.network.actual->class_id = 0;
ignore_value(virNetDevBandwidthUnplug(obj->def->bridge, class_id)); ignore_value(virNetDevBandwidthUnplug(obj->def->bridge, class_id));
...@@ -5476,12 +5476,12 @@ networkUnplugBandwidth(virNetworkObjPtr obj, ...@@ -5476,12 +5476,12 @@ networkUnplugBandwidth(virNetworkObjPtr obj,
/* update sum of 'floor'-s of attached NICs */ /* update sum of 'floor'-s of attached NICs */
obj->floor_sum -= ifaceBand->in->floor; obj->floor_sum -= ifaceBand->in->floor;
/* return class ID */ /* return class ID */
ignore_value(virBitmapClearBit(obj->class_id, ignore_value(virBitmapClearBit(obj->classIdMap,
iface->data.network.actual->class_id)); iface->data.network.actual->class_id));
/* update status file */ /* update status file */
if (virNetworkObjSaveStatus(driver->stateDir, obj) < 0) { if (virNetworkObjSaveStatus(driver->stateDir, obj) < 0) {
obj->floor_sum += ifaceBand->in->floor; obj->floor_sum += ifaceBand->in->floor;
ignore_value(virBitmapSetBit(obj->class_id, ignore_value(virBitmapSetBit(obj->classIdMap,
iface->data.network.actual->class_id)); iface->data.network.actual->class_id));
goto cleanup; goto cleanup;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册