[PATCH 09/08] interface: Introduce virInterfaceObjEndAPI

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

 



For now it'll just call the virInterfaceObjUnlock, but a future adjustment
will do something different.

The virInterfaceObjUnlock is now private to virinterfaceobj.c with a
short term forward reference.

Additionally, make virInterfaceObjLock private since it's only used in
virinterfaceobj anyway. For now this will involved creating a forward
reference, but this will go away soon too.

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

diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c
index 1e3f25c..8f839b3 100644
--- a/src/conf/virinterfaceobj.c
+++ b/src/conf/virinterfaceobj.c
@@ -44,6 +44,9 @@ struct _virInterfaceObjList {
     virInterfaceObjPtr *objs;
 };
 
+static void
+virInterfaceObjLock(virInterfaceObjPtr obj);
+
 /* virInterfaceObj manipulation */
 
 static virInterfaceObjPtr
@@ -67,14 +70,14 @@ virInterfaceObjNew(void)
 }
 
 
-void
+static void
 virInterfaceObjLock(virInterfaceObjPtr obj)
 {
     virMutexLock(&obj->lock);
 }
 
 
-void
+static void
 virInterfaceObjUnlock(virInterfaceObjPtr obj)
 {
     virMutexUnlock(&obj->lock);
@@ -82,6 +85,16 @@ virInterfaceObjUnlock(virInterfaceObjPtr obj)
 
 
 void
+virInterfaceObjEndAPI(virInterfaceObjPtr *obj)
+{
+    if (!*obj)
+        return;
+
+    virInterfaceObjUnlock(*obj);
+}
+
+
+void
 virInterfaceObjFree(virInterfaceObjPtr obj)
 {
     if (!obj)
diff --git a/src/conf/virinterfaceobj.h b/src/conf/virinterfaceobj.h
index 3934e63..2b9e1b2 100644
--- a/src/conf/virinterfaceobj.h
+++ b/src/conf/virinterfaceobj.h
@@ -28,6 +28,9 @@ typedef virInterfaceObj *virInterfaceObjPtr;
 typedef struct _virInterfaceObjList virInterfaceObjList;
 typedef virInterfaceObjList *virInterfaceObjListPtr;
 
+void
+virInterfaceObjEndAPI(virInterfaceObjPtr *obj);
+
 virInterfaceDefPtr
 virInterfaceObjGetDef(virInterfaceObjPtr obj);
 
@@ -68,12 +71,6 @@ void
 virInterfaceObjListRemove(virInterfaceObjListPtr interfaces,
                           virInterfaceObjPtr obj);
 
-void
-virInterfaceObjLock(virInterfaceObjPtr obj);
-
-void
-virInterfaceObjUnlock(virInterfaceObjPtr obj);
-
 typedef bool
 (*virInterfaceObjListFilter)(virConnectPtr conn,
                              virInterfaceDefPtr def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index aa6f351..364b32e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -910,6 +910,7 @@ virDomainObjListRename;
 
 
 # conf/virinterfaceobj.h
+virInterfaceObjEndAPI;
 virInterfaceObjGetDef;
 virInterfaceObjIsActive;
 virInterfaceObjListAssignDef;
@@ -921,9 +922,7 @@ virInterfaceObjListGetNames;
 virInterfaceObjListNew;
 virInterfaceObjListNumOfInterfaces;
 virInterfaceObjListRemove;
-virInterfaceObjLock;
 virInterfaceObjSetActive;
-virInterfaceObjUnlock;
 
 
 # conf/virnetworkobj.h
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index ac16f4f..fb95319 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1027,7 +1027,7 @@ testParseInterfaces(testDriverPtr privconn,
         }
 
         virInterfaceObjSetActive(obj, true);
-        virInterfaceObjUnlock(obj);
+        virInterfaceObjEndAPI(&obj);
     }
 
     ret = 0;
@@ -3718,7 +3718,7 @@ testInterfaceLookupByName(virConnectPtr conn,
 
     ret = virGetInterface(conn, def->name, def->mac);
 
-    virInterfaceObjUnlock(obj);
+    virInterfaceObjEndAPI(&obj);
     return ret;
 }
 
@@ -3769,7 +3769,7 @@ testInterfaceIsActive(virInterfacePtr iface)
 
     ret = virInterfaceObjIsActive(obj);
 
-    virInterfaceObjUnlock(obj);
+    virInterfaceObjEndAPI(&obj);
     return ret;
 }
 
@@ -3881,7 +3881,7 @@ testInterfaceGetXMLDesc(virInterfacePtr iface,
 
     ret = virInterfaceDefFormat(def);
 
-    virInterfaceObjUnlock(obj);
+    virInterfaceObjEndAPI(&obj);
     return ret;
 }
 
@@ -3912,8 +3912,7 @@ testInterfaceDefineXML(virConnectPtr conn,
 
  cleanup:
     virInterfaceDefFree(def);
-    if (obj)
-        virInterfaceObjUnlock(obj);
+    virInterfaceObjEndAPI(&obj);
     testDriverUnlock(privconn);
     return ret;
 }
@@ -3956,7 +3955,7 @@ testInterfaceCreate(virInterfacePtr iface,
     ret = 0;
 
  cleanup:
-    virInterfaceObjUnlock(obj);
+    virInterfaceObjEndAPI(&obj);
     return ret;
 }
 
@@ -3983,7 +3982,7 @@ testInterfaceDestroy(virInterfacePtr iface,
     ret = 0;
 
  cleanup:
-    virInterfaceObjUnlock(obj);
+    virInterfaceObjEndAPI(&obj);
     return ret;
 }
 
-- 
2.9.3

--
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