[PATCH v3 4/9] interface: Make _virInterfaceObj struct private

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

 



Move the struct into virinterfaceobj.c, create necessary accessors, and
initializers.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/conf/virinterfaceobj.c | 28 ++++++++++++++++++++++++++++
 src/conf/virinterfaceobj.h | 20 +++++++++-----------
 src/libvirt_private.syms   |  3 +++
 src/test/test_driver.c     | 20 +++++++++++---------
 4 files changed, 51 insertions(+), 20 deletions(-)

diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c
index ead9512..a2ef7f4 100644
--- a/src/conf/virinterfaceobj.c
+++ b/src/conf/virinterfaceobj.c
@@ -32,6 +32,12 @@
 
 VIR_LOG_INIT("conf.virinterfaceobj");
 
+struct _virInterfaceObj {
+    virMutex lock;
+
+    bool active;           /* true if interface is active (up) */
+    virInterfaceDefPtr def; /* The interface definition */
+};
 
 
 /* virInterfaceObj manipulation */
@@ -62,6 +68,28 @@ virInterfaceObjFree(virInterfaceObjPtr obj)
 }
 
 
+virInterfaceDefPtr
+virInterfaceObjGetDef(virInterfaceObjPtr obj)
+{
+    return obj->def;
+}
+
+
+bool
+virInterfaceObjIsActive(virInterfaceObjPtr obj)
+{
+    return obj->active;
+}
+
+
+void
+virInterfaceObjSetActive(virInterfaceObjPtr obj,
+                         bool active)
+{
+    obj->active = active;
+}
+
+
 /* virInterfaceObjList manipulation */
 int
 virInterfaceObjFindByMACString(virInterfaceObjListPtr interfaces,
diff --git a/src/conf/virinterfaceobj.h b/src/conf/virinterfaceobj.h
index ee166c6..79b6fc9 100644
--- a/src/conf/virinterfaceobj.h
+++ b/src/conf/virinterfaceobj.h
@@ -24,12 +24,6 @@
 
 typedef struct _virInterfaceObj virInterfaceObj;
 typedef virInterfaceObj *virInterfaceObjPtr;
-struct _virInterfaceObj {
-    virMutex lock;
-
-    bool active;           /* true if interface is active (up) */
-    virInterfaceDefPtr def; /* The interface definition */
-};
 
 typedef struct _virInterfaceObjList virInterfaceObjList;
 typedef virInterfaceObjList *virInterfaceObjListPtr;
@@ -38,11 +32,15 @@ struct _virInterfaceObjList {
     virInterfaceObjPtr *objs;
 };
 
-static inline bool
-virInterfaceObjIsActive(const virInterfaceObj *iface)
-{
-    return iface->active;
-}
+virInterfaceDefPtr
+virInterfaceObjGetDef(virInterfaceObjPtr obj);
+
+bool
+virInterfaceObjIsActive(virInterfaceObjPtr obj);
+
+void
+virInterfaceObjSetActive(virInterfaceObjPtr obj,
+                         bool active);
 
 int
 virInterfaceObjFindByMACString(virInterfaceObjListPtr interfaces,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 429b095..0929728 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -913,12 +913,15 @@ virDomainObjListRename;
 virInterfaceObjAssignDef;
 virInterfaceObjFindByMACString;
 virInterfaceObjFindByName;
+virInterfaceObjGetDef;
 virInterfaceObjGetNames;
+virInterfaceObjIsActive;
 virInterfaceObjListClone;
 virInterfaceObjListFree;
 virInterfaceObjLock;
 virInterfaceObjNumOfInterfaces;
 virInterfaceObjRemove;
+virInterfaceObjSetActive;
 virInterfaceObjUnlock;
 
 
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 29c31ad..1b6063a 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1025,7 +1025,7 @@ testParseInterfaces(testDriverPtr privconn,
             goto error;
         }
 
-        obj->active = 1;
+        virInterfaceObjSetActive(obj, true);
         virInterfaceObjUnlock(obj);
     }
 
@@ -3711,7 +3711,7 @@ testInterfaceLookupByName(virConnectPtr conn,
 
     if (!(obj = testInterfaceObjFindByName(privconn, name)))
         return NULL;
-    def = obj->def;
+    def = virInterfaceObjGetDef(obj);
 
     ret = virGetInterface(conn, def->name, def->mac);
 
@@ -3744,7 +3744,7 @@ testInterfaceLookupByMACString(virConnectPtr conn,
         goto cleanup;
     }
 
-    def = obj->def;
+    def = virInterfaceObjGetDef(obj);
     ret = virGetInterface(conn, def->name, def->mac);
 
  cleanup:
@@ -3870,14 +3870,16 @@ testInterfaceGetXMLDesc(virInterfacePtr iface,
 {
     testDriverPtr privconn = iface->conn->privateData;
     virInterfaceObjPtr obj;
+    virInterfaceDefPtr def;
     char *ret = NULL;
 
     virCheckFlags(0, NULL);
 
     if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
         return NULL;
+    def = virInterfaceObjGetDef(obj);
 
-    ret = virInterfaceDefFormat(obj->def);
+    ret = virInterfaceDefFormat(def);
 
     virInterfaceObjUnlock(obj);
     return ret;
@@ -3904,7 +3906,7 @@ testInterfaceDefineXML(virConnectPtr conn,
     if ((obj = virInterfaceObjAssignDef(&privconn->ifaces, def)) == NULL)
         goto cleanup;
     def = NULL;
-    objdef = obj->def;
+    objdef = virInterfaceObjGetDef(obj);
 
     ret = virGetInterface(conn, objdef->name, objdef->mac);
 
@@ -3945,12 +3947,12 @@ testInterfaceCreate(virInterfacePtr iface,
     if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
         return -1;
 
-    if (obj->active != 0) {
+    if (virInterfaceObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID, NULL);
         goto cleanup;
     }
 
-    obj->active = 1;
+    virInterfaceObjSetActive(obj, true);
     ret = 0;
 
  cleanup:
@@ -3972,12 +3974,12 @@ testInterfaceDestroy(virInterfacePtr iface,
     if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
         return -1;
 
-    if (obj->active == 0) {
+    if (!virInterfaceObjIsActive(obj)) {
         virReportError(VIR_ERR_OPERATION_INVALID, NULL);
         goto cleanup;
     }
 
-    obj->active = 0;
+    virInterfaceObjSetActive(obj, false);
     ret = 0;
 
  cleanup:
-- 
2.9.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux