mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
network: Introduce virNetworkObj{Is|Set}Active
In order to privatize the virNetworkObj create accessors in virnetworkobj in order to handle the get/set of the active value. Also rather than an unsigned int, convert it to a boolean to match other drivers representation and the reality of what it is. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
f57d8a7b32
commit
9e8227d76b
@ -129,6 +129,21 @@ virNetworkObjGetNewDef(virNetworkObjPtr obj)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
virNetworkObjIsActive(virNetworkObjPtr obj)
|
||||
{
|
||||
return obj->active;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
virNetworkObjSetActive(virNetworkObjPtr obj,
|
||||
bool active)
|
||||
{
|
||||
obj->active = active;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
virNetworkObjIsAutostart(virNetworkObjPtr obj)
|
||||
{
|
||||
@ -924,7 +939,7 @@ virNetworkLoadState(virNetworkObjListPtr nets,
|
||||
net->floor_sum = floor_sum_val;
|
||||
|
||||
net->taint = taint;
|
||||
net->active = 1; /* any network with a state file is by definition active */
|
||||
net->active = true; /* any network with a state file is by definition active */
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(configFile);
|
||||
|
@ -31,7 +31,7 @@ struct _virNetworkObj {
|
||||
|
||||
pid_t dnsmasqPid;
|
||||
pid_t radvdPid;
|
||||
unsigned int active : 1;
|
||||
bool active;
|
||||
bool autostart;
|
||||
unsigned int persistent : 1;
|
||||
|
||||
@ -60,6 +60,13 @@ virNetworkObjSetDef(virNetworkObjPtr obj,
|
||||
virNetworkDefPtr
|
||||
virNetworkObjGetNewDef(virNetworkObjPtr obj);
|
||||
|
||||
bool
|
||||
virNetworkObjIsActive(virNetworkObjPtr obj);
|
||||
|
||||
void
|
||||
virNetworkObjSetActive(virNetworkObjPtr obj,
|
||||
bool active);
|
||||
|
||||
bool
|
||||
virNetworkObjIsAutostart(virNetworkObjPtr obj);
|
||||
|
||||
@ -119,12 +126,6 @@ virNetworkObjEndAPI(virNetworkObjPtr *net);
|
||||
typedef struct _virNetworkObjList virNetworkObjList;
|
||||
typedef virNetworkObjList *virNetworkObjListPtr;
|
||||
|
||||
static inline int
|
||||
virNetworkObjIsActive(const virNetworkObj *net)
|
||||
{
|
||||
return net->active;
|
||||
}
|
||||
|
||||
virNetworkObjListPtr
|
||||
virNetworkObjListNew(void);
|
||||
|
||||
|
@ -950,6 +950,7 @@ virNetworkObjGetMacMap;
|
||||
virNetworkObjGetNewDef;
|
||||
virNetworkObjGetPersistentDef;
|
||||
virNetworkObjGetRadvdPid;
|
||||
virNetworkObjIsActive;
|
||||
virNetworkObjIsAutostart;
|
||||
virNetworkObjListExport;
|
||||
virNetworkObjListForEach;
|
||||
@ -965,6 +966,7 @@ virNetworkObjNew;
|
||||
virNetworkObjRemoveInactive;
|
||||
virNetworkObjReplacePersistentDef;
|
||||
virNetworkObjSaveStatus;
|
||||
virNetworkObjSetActive;
|
||||
virNetworkObjSetAutostart;
|
||||
virNetworkObjSetDef;
|
||||
virNetworkObjSetDefTransient;
|
||||
|
@ -452,7 +452,7 @@ networkUpdateState(virNetworkObjPtr obj,
|
||||
case VIR_NETWORK_FORWARD_OPEN:
|
||||
/* If bridge doesn't exist, then mark it inactive */
|
||||
if (!(def->bridge && virNetDevExists(def->bridge) == 1))
|
||||
obj->active = 0;
|
||||
virNetworkObjSetActive(obj, false);
|
||||
|
||||
if (!(macMapFile = virMacMapFileName(driver->dnsmasqStateDir,
|
||||
def->bridge)))
|
||||
@ -468,7 +468,7 @@ networkUpdateState(virNetworkObjPtr obj,
|
||||
case VIR_NETWORK_FORWARD_BRIDGE:
|
||||
if (def->bridge) {
|
||||
if (virNetDevExists(def->bridge) != 1)
|
||||
obj->active = 0;
|
||||
virNetworkObjSetActive(obj, false);
|
||||
break;
|
||||
}
|
||||
/* intentionally drop through to common case for all
|
||||
@ -487,7 +487,7 @@ networkUpdateState(virNetworkObjPtr obj,
|
||||
}
|
||||
|
||||
/* Try and read dnsmasq/radvd pids of active networks */
|
||||
if (obj->active && def->ips && (def->nips > 0)) {
|
||||
if (virNetworkObjIsActive(obj) && def->ips && (def->nips > 0)) {
|
||||
pid_t radvdPid;
|
||||
pid_t dnsmasqPid;
|
||||
char *radvdpidbase;
|
||||
@ -2790,7 +2790,7 @@ networkStartNetwork(virNetworkDriverStatePtr driver,
|
||||
if (virNetworkObjSaveStatus(driver->stateDir, obj) < 0)
|
||||
goto cleanup;
|
||||
|
||||
obj->active = 1;
|
||||
virNetworkObjSetActive(obj, true);
|
||||
VIR_INFO("Network '%s' started up", def->name);
|
||||
ret = 0;
|
||||
|
||||
@ -2860,7 +2860,7 @@ networkShutdownNetwork(virNetworkDriverStatePtr driver,
|
||||
networkRunHook(obj, NULL, NULL, VIR_HOOK_NETWORK_OP_STOPPED,
|
||||
VIR_HOOK_SUBOP_END);
|
||||
|
||||
obj->active = 0;
|
||||
virNetworkObjSetActive(obj, false);
|
||||
virNetworkObjUnsetDefTransient(obj);
|
||||
return ret;
|
||||
}
|
||||
|
@ -988,7 +988,7 @@ testParseNetworks(testDriverPtr privconn,
|
||||
goto error;
|
||||
}
|
||||
|
||||
obj->active = 1;
|
||||
virNetworkObjSetActive(obj, true);
|
||||
virNetworkObjEndAPI(&obj);
|
||||
}
|
||||
|
||||
@ -3404,7 +3404,7 @@ testNetworkCreateXML(virConnectPtr conn, const char *xml)
|
||||
goto cleanup;
|
||||
newDef = NULL;
|
||||
def = virNetworkObjGetDef(obj);
|
||||
obj->active = 1;
|
||||
virNetworkObjSetActive(obj, true);
|
||||
|
||||
event = virNetworkEventLifecycleNew(def->name, def->uuid,
|
||||
VIR_NETWORK_EVENT_STARTED,
|
||||
@ -3546,7 +3546,7 @@ testNetworkCreate(virNetworkPtr net)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
obj->active = 1;
|
||||
virNetworkObjSetActive(obj, true);
|
||||
event = virNetworkEventLifecycleNew(def->name, def->uuid,
|
||||
VIR_NETWORK_EVENT_STARTED,
|
||||
0);
|
||||
@ -3572,7 +3572,7 @@ testNetworkDestroy(virNetworkPtr net)
|
||||
goto cleanup;
|
||||
def = virNetworkObjGetDef(obj);
|
||||
|
||||
obj->active = 0;
|
||||
virNetworkObjSetActive(obj, false);
|
||||
event = virNetworkEventLifecycleNew(def->name, def->uuid,
|
||||
VIR_NETWORK_EVENT_STOPPED,
|
||||
0);
|
||||
|
Loading…
Reference in New Issue
Block a user