提交 7435404f 编写于 作者: J John Ferlan

network: Introduce virNetworkObjGetClassIdMap

In preparation for privatizing virNetworkObj, create accessor function to
fetch the @classIdMap.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 d5d699ec
...@@ -137,6 +137,13 @@ virNetworkObjSetRadvdPid(virNetworkObjPtr obj, ...@@ -137,6 +137,13 @@ virNetworkObjSetRadvdPid(virNetworkObjPtr obj,
} }
virBitmapPtr
virNetworkObjGetClassIdMap(virNetworkObjPtr obj)
{
return obj->classIdMap;
}
virMacMapPtr virMacMapPtr
virNetworkObjGetMacMap(virNetworkObjPtr obj) virNetworkObjGetMacMap(virNetworkObjPtr obj)
{ {
......
...@@ -67,6 +67,9 @@ void ...@@ -67,6 +67,9 @@ void
virNetworkObjSetRadvdPid(virNetworkObjPtr obj, virNetworkObjSetRadvdPid(virNetworkObjPtr obj,
pid_t radvdPid); pid_t radvdPid);
virBitmapPtr
virNetworkObjGetClassIdMap(virNetworkObjPtr obj);
void void
virNetworkObjSetMacMap(virNetworkObjPtr obj, virNetworkObjSetMacMap(virNetworkObjPtr obj,
virMacMapPtr macmap); virMacMapPtr macmap);
......
...@@ -942,6 +942,7 @@ virNetworkObjDeleteConfig; ...@@ -942,6 +942,7 @@ virNetworkObjDeleteConfig;
virNetworkObjEndAPI; virNetworkObjEndAPI;
virNetworkObjFindByName; virNetworkObjFindByName;
virNetworkObjFindByUUID; virNetworkObjFindByUUID;
virNetworkObjGetClassIdMap;
virNetworkObjGetDnsmasqPid; virNetworkObjGetDnsmasqPid;
virNetworkObjGetMacMap; virNetworkObjGetMacMap;
virNetworkObjGetPersistentDef; virNetworkObjGetPersistentDef;
......
...@@ -5346,10 +5346,11 @@ static ssize_t ...@@ -5346,10 +5346,11 @@ static ssize_t
networkNextClassID(virNetworkObjPtr obj) networkNextClassID(virNetworkObjPtr obj)
{ {
ssize_t ret = 0; ssize_t ret = 0;
virBitmapPtr classIdMap = virNetworkObjGetClassIdMap(obj);
ret = virBitmapNextClearBit(obj->classIdMap, -1); ret = virBitmapNextClearBit(classIdMap, -1);
if (ret < 0 || virBitmapSetBit(obj->classIdMap, ret) < 0) if (ret < 0 || virBitmapSetBit(classIdMap, ret) < 0)
return -1; return -1;
return ret; return ret;
...@@ -5363,6 +5364,7 @@ networkPlugBandwidthImpl(virNetworkObjPtr obj, ...@@ -5363,6 +5364,7 @@ networkPlugBandwidthImpl(virNetworkObjPtr obj,
unsigned long long new_rate) unsigned long long new_rate)
{ {
virNetworkDriverStatePtr driver = networkGetDriver(); virNetworkDriverStatePtr driver = networkGetDriver();
virBitmapPtr classIdMap = virNetworkObjGetClassIdMap(obj);
ssize_t class_id = 0; ssize_t class_id = 0;
int plug_ret; int plug_ret;
int ret = -1; int ret = -1;
...@@ -5387,7 +5389,7 @@ networkPlugBandwidthImpl(virNetworkObjPtr obj, ...@@ -5387,7 +5389,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->classIdMap, class_id)); ignore_value(virBitmapClearBit(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));
...@@ -5451,6 +5453,7 @@ static int ...@@ -5451,6 +5453,7 @@ static int
networkUnplugBandwidth(virNetworkObjPtr obj, networkUnplugBandwidth(virNetworkObjPtr obj,
virDomainNetDefPtr iface) virDomainNetDefPtr iface)
{ {
virBitmapPtr classIdMap = virNetworkObjGetClassIdMap(obj);
virNetworkDriverStatePtr driver = networkGetDriver(); virNetworkDriverStatePtr driver = networkGetDriver();
int ret = 0; int ret = 0;
unsigned long long new_rate; unsigned long long new_rate;
...@@ -5476,12 +5479,12 @@ networkUnplugBandwidth(virNetworkObjPtr obj, ...@@ -5476,12 +5479,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->classIdMap, ignore_value(virBitmapClearBit(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->classIdMap, ignore_value(virBitmapSetBit(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.
先完成此消息的编辑!
想要评论请 注册