network: Introduce virNetworkObjIsPersistent

In preparation to privatize the virNetworkObj - create an accessor function
to get the current @persistent value.  Also change the value to a bool rather
than an unsigned int (since that's how it's generated anyway).

Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
John Ferlan 2017-05-10 07:29:57 -04:00
parent 9e8227d76b
commit bc9868aaf2
5 changed files with 19 additions and 7 deletions

View File

@ -144,6 +144,13 @@ virNetworkObjSetActive(virNetworkObjPtr obj,
} }
bool
virNetworkObjIsPersistent(virNetworkObjPtr obj)
{
return obj->persistent;
}
bool bool
virNetworkObjIsAutostart(virNetworkObjPtr obj) virNetworkObjIsAutostart(virNetworkObjPtr obj)
{ {

View File

@ -33,7 +33,7 @@ struct _virNetworkObj {
pid_t radvdPid; pid_t radvdPid;
bool active; bool active;
bool autostart; bool autostart;
unsigned int persistent : 1; bool persistent;
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 */
@ -67,6 +67,9 @@ void
virNetworkObjSetActive(virNetworkObjPtr obj, virNetworkObjSetActive(virNetworkObjPtr obj,
bool active); bool active);
bool
virNetworkObjIsPersistent(virNetworkObjPtr obj);
bool bool
virNetworkObjIsAutostart(virNetworkObjPtr obj); virNetworkObjIsAutostart(virNetworkObjPtr obj);

View File

@ -952,6 +952,7 @@ virNetworkObjGetPersistentDef;
virNetworkObjGetRadvdPid; virNetworkObjGetRadvdPid;
virNetworkObjIsActive; virNetworkObjIsActive;
virNetworkObjIsAutostart; virNetworkObjIsAutostart;
virNetworkObjIsPersistent;
virNetworkObjListExport; virNetworkObjListExport;
virNetworkObjListForEach; virNetworkObjListForEach;
virNetworkObjListGetNames; virNetworkObjListGetNames;

View File

@ -3100,7 +3100,7 @@ networkIsPersistent(virNetworkPtr net)
if (virNetworkIsPersistentEnsureACL(net->conn, virNetworkObjGetDef(obj)) < 0) if (virNetworkIsPersistentEnsureACL(net->conn, virNetworkObjGetDef(obj)) < 0)
goto cleanup; goto cleanup;
ret = obj->persistent; ret = virNetworkObjIsPersistent(obj);
cleanup: cleanup:
virNetworkObjEndAPI(&obj); virNetworkObjEndAPI(&obj);
@ -3598,7 +3598,7 @@ networkUndefine(virNetworkPtr net)
if (virNetworkObjIsActive(obj)) if (virNetworkObjIsActive(obj))
active = true; active = true;
if (!obj->persistent) { if (!virNetworkObjIsPersistent(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("can't undefine transient network")); _("can't undefine transient network"));
goto cleanup; goto cleanup;
@ -3881,7 +3881,8 @@ networkDestroy(virNetworkPtr net)
VIR_NETWORK_EVENT_STOPPED, VIR_NETWORK_EVENT_STOPPED,
0); 0);
if (!obj->persistent && networkRemoveInactive(driver, obj) < 0) { if (!virNetworkObjIsPersistent(obj) &&
networkRemoveInactive(driver, obj) < 0) {
ret = -1; ret = -1;
goto cleanup; goto cleanup;
} }
@ -3997,7 +3998,7 @@ networkSetAutostart(virNetworkPtr net,
if (virNetworkSetAutostartEnsureACL(net->conn, def) < 0) if (virNetworkSetAutostartEnsureACL(net->conn, def) < 0)
goto cleanup; goto cleanup;
if (!obj->persistent) { if (!virNetworkObjIsPersistent(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot set autostart for transient network")); "%s", _("cannot set autostart for transient network"));
goto cleanup; goto cleanup;

View File

@ -3377,7 +3377,7 @@ testNetworkIsPersistent(virNetworkPtr net)
if (!(obj = testNetworkObjFindByUUID(privconn, net->uuid))) if (!(obj = testNetworkObjFindByUUID(privconn, net->uuid)))
goto cleanup; goto cleanup;
ret = obj->persistent; ret = virNetworkObjIsPersistent(obj);
cleanup: cleanup:
virNetworkObjEndAPI(&obj); virNetworkObjEndAPI(&obj);
@ -3576,7 +3576,7 @@ testNetworkDestroy(virNetworkPtr net)
event = virNetworkEventLifecycleNew(def->name, def->uuid, event = virNetworkEventLifecycleNew(def->name, def->uuid,
VIR_NETWORK_EVENT_STOPPED, VIR_NETWORK_EVENT_STOPPED,
0); 0);
if (!obj->persistent) if (!virNetworkObjIsPersistent(obj))
virNetworkObjRemoveInactive(privconn->networks, obj); virNetworkObjRemoveInactive(privconn->networks, obj);
ret = 0; ret = 0;