[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v2 13/20] 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>
---
 src/conf/virnetworkobj.c    | 7 +++++++
 src/conf/virnetworkobj.h    | 5 ++++-
 src/libvirt_private.syms    | 1 +
 src/network/bridge_driver.c | 9 +++++----
 src/test/test_driver.c      | 4 ++--
 5 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index a195494..37b76e5 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -144,6 +144,13 @@ virNetworkObjSetActive(virNetworkObjPtr obj,
 }
 
 
+bool
+virNetworkObjIsPersistent(virNetworkObjPtr obj)
+{
+    return obj->persistent;
+}
+
+
 int
 virNetworkObjGetAutostart(virNetworkObjPtr obj)
 {
diff --git a/src/conf/virnetworkobj.h b/src/conf/virnetworkobj.h
index 8b778c8..96f9eff 100644
--- a/src/conf/virnetworkobj.h
+++ b/src/conf/virnetworkobj.h
@@ -33,7 +33,7 @@ struct _virNetworkObj {
     pid_t radvdPid;
     bool active;
     int 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);
+
 int
 virNetworkObjGetAutostart(virNetworkObjPtr obj);
 
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8796258..2497af0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -954,6 +954,7 @@ virNetworkObjGetNewDef;
 virNetworkObjGetPersistentDef;
 virNetworkObjGetRadvdPid;
 virNetworkObjIsActive;
+virNetworkObjIsPersistent;
 virNetworkObjListExport;
 virNetworkObjListForEach;
 virNetworkObjListGetNames;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index f423c82..2433e4f 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -3099,7 +3099,7 @@ networkIsPersistent(virNetworkPtr net)
     if (virNetworkIsPersistentEnsureACL(net->conn, virNetworkObjGetDef(obj)) < 0)
         goto cleanup;
 
-    ret = obj->persistent;
+    ret = virNetworkObjIsPersistent(obj);
 
  cleanup:
     virNetworkObjEndAPI(&obj);
@@ -3597,7 +3597,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;
@@ -3875,7 +3875,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;
     }
@@ -3990,7 +3991,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;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 698488e..e306f1e 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -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;
-- 
2.9.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]