[PATCH v2 15/20] network: Have virNetworkObjNew lock the returned object

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

 



Forces callers to use the virNetworkObjEndAPI properly.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/conf/virnetworkobj.c    | 4 ++--
 tests/networkxml2conftest.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index edea6f5..037186e 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -87,6 +87,8 @@ virNetworkObjNew(void)
     ignore_value(virBitmapSetBit(obj->classIdMap, 1));
     ignore_value(virBitmapSetBit(obj->classIdMap, 2));
 
+    virObjectLock(obj);
+
     return obj;
 
  error:
@@ -590,8 +592,6 @@ virNetworkObjAssignDefLocked(virNetworkObjListPtr nets,
         if (!(obj = virNetworkObjNew()))
               goto cleanup;
 
-        virObjectLock(obj);
-
         virUUIDFormat(def->uuid, uuidstr);
         if (virHashAddEntry(nets->objs, uuidstr, obj) < 0)
             goto cleanup;
diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c
index 6841810..4251a22 100644
--- a/tests/networkxml2conftest.c
+++ b/tests/networkxml2conftest.c
@@ -67,7 +67,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr
     VIR_FREE(actual);
     VIR_FREE(pidfile);
     virCommandFree(cmd);
-    virObjectUnref(obj);
+    virNetworkObjEndAPI(&obj);
     dnsmasqContextFree(dctx);
     return ret;
 }
-- 
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