mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
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:
parent
9e8227d76b
commit
bc9868aaf2
@ -144,6 +144,13 @@ virNetworkObjSetActive(virNetworkObjPtr obj,
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
virNetworkObjIsPersistent(virNetworkObjPtr obj)
|
||||
{
|
||||
return obj->persistent;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
virNetworkObjIsAutostart(virNetworkObjPtr obj)
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ struct _virNetworkObj {
|
||||
pid_t radvdPid;
|
||||
bool active;
|
||||
bool autostart;
|
||||
unsigned int persistent : 1;
|
||||
bool persistent;
|
||||
|
||||
virNetworkDefPtr def; /* The current definition */
|
||||
virNetworkDefPtr newDef; /* New definition to activate at shutdown */
|
||||
@ -67,6 +67,9 @@ void
|
||||
virNetworkObjSetActive(virNetworkObjPtr obj,
|
||||
bool active);
|
||||
|
||||
bool
|
||||
virNetworkObjIsPersistent(virNetworkObjPtr obj);
|
||||
|
||||
bool
|
||||
virNetworkObjIsAutostart(virNetworkObjPtr obj);
|
||||
|
||||
|
@ -952,6 +952,7 @@ virNetworkObjGetPersistentDef;
|
||||
virNetworkObjGetRadvdPid;
|
||||
virNetworkObjIsActive;
|
||||
virNetworkObjIsAutostart;
|
||||
virNetworkObjIsPersistent;
|
||||
virNetworkObjListExport;
|
||||
virNetworkObjListForEach;
|
||||
virNetworkObjListGetNames;
|
||||
|
@ -3100,7 +3100,7 @@ networkIsPersistent(virNetworkPtr net)
|
||||
if (virNetworkIsPersistentEnsureACL(net->conn, virNetworkObjGetDef(obj)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = obj->persistent;
|
||||
ret = virNetworkObjIsPersistent(obj);
|
||||
|
||||
cleanup:
|
||||
virNetworkObjEndAPI(&obj);
|
||||
@ -3598,7 +3598,7 @@ networkUndefine(virNetworkPtr net)
|
||||
if (virNetworkObjIsActive(obj))
|
||||
active = true;
|
||||
|
||||
if (!obj->persistent) {
|
||||
if (!virNetworkObjIsPersistent(obj)) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("can't undefine transient network"));
|
||||
goto cleanup;
|
||||
@ -3881,7 +3881,8 @@ networkDestroy(virNetworkPtr net)
|
||||
VIR_NETWORK_EVENT_STOPPED,
|
||||
0);
|
||||
|
||||
if (!obj->persistent && networkRemoveInactive(driver, obj) < 0) {
|
||||
if (!virNetworkObjIsPersistent(obj) &&
|
||||
networkRemoveInactive(driver, obj) < 0) {
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
@ -3997,7 +3998,7 @@ networkSetAutostart(virNetworkPtr net,
|
||||
if (virNetworkSetAutostartEnsureACL(net->conn, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!obj->persistent) {
|
||||
if (!virNetworkObjIsPersistent(obj)) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
"%s", _("cannot set autostart for transient network"));
|
||||
goto cleanup;
|
||||
|
@ -3377,7 +3377,7 @@ testNetworkIsPersistent(virNetworkPtr net)
|
||||
if (!(obj = testNetworkObjFindByUUID(privconn, net->uuid)))
|
||||
goto cleanup;
|
||||
|
||||
ret = obj->persistent;
|
||||
ret = virNetworkObjIsPersistent(obj);
|
||||
|
||||
cleanup:
|
||||
virNetworkObjEndAPI(&obj);
|
||||
@ -3576,7 +3576,7 @@ testNetworkDestroy(virNetworkPtr net)
|
||||
event = virNetworkEventLifecycleNew(def->name, def->uuid,
|
||||
VIR_NETWORK_EVENT_STOPPED,
|
||||
0);
|
||||
if (!obj->persistent)
|
||||
if (!virNetworkObjIsPersistent(obj))
|
||||
virNetworkObjRemoveInactive(privconn->networks, obj);
|
||||
|
||||
ret = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user