[PATCH v2 10/24] network_conf: Make virNetworkObj actually virObject

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

 



So far it's just a structure which happens to have 'Obj' in its
name, but otherwise it not related to virObject at all. No
reference counting, not virObjectLock(), nothing.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 cfg.mk                            |   2 -
 src/conf/network_conf.c           | 135 ++++++++++++++++++++------------------
 src/conf/network_conf.h           |   8 +--
 src/libvirt_private.syms          |   4 +-
 src/network/bridge_driver.c       |  56 ++++++++--------
 src/parallels/parallels_network.c |  16 ++---
 src/test/test_driver.c            |  32 ++++-----
 tests/networkxml2conftest.c       |   4 +-
 tests/objectlocking.ml            |   2 -
 9 files changed, 129 insertions(+), 130 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index 07a794a..6885f9e 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -160,7 +160,6 @@ useless_free_options =				\
   --name=virNWFilterRuleDefFree			\
   --name=virNWFilterRuleInstFree		\
   --name=virNetworkDefFree			\
-  --name=virNetworkObjFree			\
   --name=virNodeDeviceDefFree			\
   --name=virNodeDeviceObjFree			\
   --name=virObjectUnref                         \
@@ -249,7 +248,6 @@ useless_free_options =				\
 # y virNetworkDefFree
 # n virNetworkFree (returns int)
 # n virNetworkFreeName (returns int)
-# y virNetworkObjFree
 # n virNodeDevCapsDefFree FIXME
 # y virNodeDeviceDefFree
 # n virNodeDeviceFree (returns int)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 9c1d578..c1dc694 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -80,11 +80,19 @@ VIR_ENUM_IMPL(virNetworkForwardDriverName,
 VIR_ENUM_IMPL(virNetworkTaint, VIR_NETWORK_TAINT_LAST,
               "hook-script");
 
+static virClassPtr virNetworkObjClass;
 static virClassPtr virNetworkObjListClass;
+static void virNetworkObjDispose(void *obj);
 static void virNetworkObjListDispose(void *obj);
 
 static int virNetworkObjOnceInit(void)
 {
+    if (!(virNetworkObjClass = virClassNew(virClassForObjectLockable(),
+                                           "virNetworkObj",
+                                           sizeof(virNetworkObj),
+                                           virNetworkObjDispose)))
+        return -1;
+
     if (!(virNetworkObjListClass = virClassNew(virClassForObject(),
                                                "virNetworkObjList",
                                                sizeof(virNetworkObjList),
@@ -96,6 +104,32 @@ static int virNetworkObjOnceInit(void)
 
 VIR_ONCE_GLOBAL_INIT(virNetworkObj)
 
+virNetworkObjPtr
+virNetworkObjNew(void)
+{
+    virNetworkObjPtr net;
+
+    if (virNetworkObjInitialize() < 0)
+        return NULL;
+
+    if (!(net = virObjectLockableNew(virNetworkObjClass)))
+        return NULL;
+
+    if (!(net->class_id = virBitmapNew(CLASS_ID_BITMAP_SIZE)))
+        goto error;
+
+    /* The first three class IDs are already taken */
+    ignore_value(virBitmapSetBit(net->class_id, 0));
+    ignore_value(virBitmapSetBit(net->class_id, 1));
+    ignore_value(virBitmapSetBit(net->class_id, 2));
+
+    return net;
+
+ error:
+    virObjectUnref(net);
+    return NULL;
+}
+
 virNetworkObjListPtr virNetworkObjListNew(void)
 {
     virNetworkObjListPtr nets;
@@ -115,10 +149,10 @@ virNetworkObjPtr virNetworkObjFindByUUID(virNetworkObjListPtr nets,
     size_t i;
 
     for (i = 0; i < nets->count; i++) {
-        virNetworkObjLock(nets->objs[i]);
+        virObjectLock(nets->objs[i]);
         if (!memcmp(nets->objs[i]->def->uuid, uuid, VIR_UUID_BUFLEN))
             return nets->objs[i];
-        virNetworkObjUnlock(nets->objs[i]);
+        virObjectUnlock(nets->objs[i]);
     }
 
     return NULL;
@@ -130,10 +164,10 @@ virNetworkObjPtr virNetworkObjFindByName(virNetworkObjListPtr nets,
     size_t i;
 
     for (i = 0; i < nets->count; i++) {
-        virNetworkObjLock(nets->objs[i]);
+        virObjectLock(nets->objs[i]);
         if (STREQ(nets->objs[i]->def->name, name))
             return nets->objs[i];
-        virNetworkObjUnlock(nets->objs[i]);
+        virObjectUnlock(nets->objs[i]);
     }
 
     return NULL;
@@ -297,18 +331,14 @@ virNetworkDefFree(virNetworkDefPtr def)
     VIR_FREE(def);
 }
 
-void virNetworkObjFree(virNetworkObjPtr net)
+static void
+virNetworkObjDispose(void *obj)
 {
-    if (!net)
-        return;
+    virNetworkObjPtr net = obj;
 
     virNetworkDefFree(net->def);
     virNetworkDefFree(net->newDef);
     virBitmapFree(net->class_id);
-
-    virMutexDestroy(&net->lock);
-
-    VIR_FREE(net);
 }
 
 static void
@@ -318,7 +348,7 @@ virNetworkObjListDispose(void *obj)
     size_t i;
 
     for (i = 0; i < nets->count; i++)
-        virNetworkObjFree(nets->objs[i]);
+        virObjectUnref(nets->objs[i]);
 
     VIR_FREE(nets->objs);
 }
@@ -409,32 +439,20 @@ virNetworkAssignDef(virNetworkObjListPtr nets,
         return network;
     }
 
-    if (VIR_ALLOC(network) < 0)
+    if (!(network = virNetworkObjNew()))
         return NULL;
-    if (virMutexInit(&network->lock) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "%s", _("cannot initialize mutex"));
-        VIR_FREE(network);
-        return NULL;
-    }
-    virNetworkObjLock(network);
+    virObjectLock(network);
 
-    if (VIR_APPEND_ELEMENT_COPY(nets->objs, nets->count, network) < 0 ||
-        !(network->class_id = virBitmapNew(CLASS_ID_BITMAP_SIZE)))
+    if (VIR_APPEND_ELEMENT_COPY(nets->objs, nets->count, network) < 0)
         goto error;
 
-    /* The first three class IDs are already taken */
-    ignore_value(virBitmapSetBit(network->class_id, 0));
-    ignore_value(virBitmapSetBit(network->class_id, 1));
-    ignore_value(virBitmapSetBit(network->class_id, 2));
-
     network->def = def;
     network->persistent = !live;
     return network;
 
  error:
-    virNetworkObjUnlock(network);
-    virNetworkObjFree(network);
+    virObjectUnlock(network);
+    virObjectUnref(network);
     return NULL;
 
 }
@@ -602,17 +620,16 @@ void virNetworkRemoveInactive(virNetworkObjListPtr nets,
 {
     size_t i;
 
-    virNetworkObjUnlock(net);
+    virObjectUnlock(net);
     for (i = 0; i < nets->count; i++) {
-        virNetworkObjLock(nets->objs[i]);
+        virObjectLock(nets->objs[i]);
         if (nets->objs[i] == net) {
-            virNetworkObjUnlock(nets->objs[i]);
-            virNetworkObjFree(nets->objs[i]);
-
             VIR_DELETE_ELEMENT(nets->objs, i, nets->count);
+            virObjectUnlock(net);
+            virObjectUnref(net);
             break;
         }
-        virNetworkObjUnlock(nets->objs[i]);
+        virObjectUnlock(nets->objs[i]);
     }
 }
 
@@ -3014,7 +3031,7 @@ virNetworkLoadAllState(virNetworkObjListPtr nets,
             continue;
 
         if ((net = virNetworkLoadState(nets, stateDir, entry->d_name)))
-            virNetworkObjUnlock(net);
+            virObjectUnlock(net);
     }
 
     closedir(dir);
@@ -3055,7 +3072,7 @@ int virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
                                    autostartDir,
                                    entry->d_name);
         if (net)
-            virNetworkObjUnlock(net);
+            virObjectUnlock(net);
     }
 
     closedir(dir);
@@ -3110,12 +3127,12 @@ int virNetworkBridgeInUse(virNetworkObjListPtr nets,
     unsigned int ret = 0;
 
     for (i = 0; i < nets->count; i++) {
-        virNetworkObjLock(nets->objs[i]);
+        virObjectLock(nets->objs[i]);
         if (nets->objs[i]->def->bridge &&
             STREQ(nets->objs[i]->def->bridge, bridge) &&
             !(skipname && STREQ(nets->objs[i]->def->name, skipname)))
                 ret = 1;
-        virNetworkObjUnlock(nets->objs[i]);
+        virObjectUnlock(nets->objs[i]);
     }
 
     return ret;
@@ -4223,21 +4240,11 @@ virNetworkObjIsDuplicate(virNetworkObjListPtr nets,
 
  cleanup:
     if (net)
-        virNetworkObjUnlock(net);
+        virObjectUnlock(net);
     return ret;
 }
 
 
-void virNetworkObjLock(virNetworkObjPtr obj)
-{
-    virMutexLock(&obj->lock);
-}
-
-void virNetworkObjUnlock(virNetworkObjPtr obj)
-{
-    virMutexUnlock(&obj->lock);
-}
-
 #define MATCH(FLAG) (flags & (FLAG))
 static bool
 virNetworkMatch(virNetworkObjPtr netobj,
@@ -4289,21 +4296,21 @@ virNetworkObjListExport(virConnectPtr conn,
 
     for (i = 0; i < netobjs->count; i++) {
         virNetworkObjPtr netobj = netobjs->objs[i];
-        virNetworkObjLock(netobj);
+        virObjectLock(netobj);
         if ((!filter || filter(conn, netobj->def)) &&
             virNetworkMatch(netobj, flags)) {
             if (nets) {
                 if (!(net = virGetNetwork(conn,
                                           netobj->def->name,
                                           netobj->def->uuid))) {
-                    virNetworkObjUnlock(netobj);
+                    virObjectUnlock(netobj);
                     goto cleanup;
                 }
                 tmp_nets[nnets] = net;
             }
             nnets++;
         }
-        virNetworkObjUnlock(netobj);
+        virObjectUnlock(netobj);
     }
 
     if (tmp_nets) {
@@ -4365,21 +4372,21 @@ virNetworkObjListGetNames(virNetworkObjListPtr nets,
 
     for (i = 0; i < nets->count && got < nnames; i++) {
         virNetworkObjPtr obj = nets->objs[i];
-        virNetworkObjLock(obj);
+        virObjectLock(obj);
         if (filter && !filter(conn, obj->def)) {
-            virNetworkObjUnlock(obj);
+            virObjectUnlock(obj);
             continue;
         }
 
         if ((active && virNetworkObjIsActive(obj)) ||
             (!active && !virNetworkObjIsActive(obj))) {
             if (VIR_STRDUP(names[got], obj->def->name) < 0) {
-                virNetworkObjUnlock(obj);
+                virObjectUnlock(obj);
                 goto error;
             }
             got++;
         }
-        virNetworkObjUnlock(obj);
+        virObjectUnlock(obj);
     }
 
     return got;
@@ -4401,16 +4408,16 @@ virNetworkObjListNumOfNetworks(virNetworkObjListPtr nets,
 
     for (i = 0; i < nets->count; i++) {
         virNetworkObjPtr obj = nets->objs[i];
-        virNetworkObjLock(obj);
+        virObjectLock(obj);
         if (filter && !filter(conn, obj->def)) {
-            virNetworkObjUnlock(obj);
+            virObjectUnlock(obj);
             continue;
         }
 
         if ((active && virNetworkObjIsActive(obj)) ||
             (!active && !virNetworkObjIsActive(obj)))
             count++;
-        virNetworkObjUnlock(obj);
+        virObjectUnlock(obj);
     }
 
     return count;
@@ -4433,15 +4440,15 @@ virNetworkObjListPrune(virNetworkObjListPtr nets,
     while (i < nets->count) {
         virNetworkObjPtr obj = nets->objs[i];
 
-        virNetworkObjLock(obj);
+        virObjectLock(obj);
 
         if (virNetworkMatch(obj, flags)) {
-            virNetworkObjUnlock(obj);
-            virNetworkObjFree(obj);
+            virObjectUnlock(obj);
+            virObjectUnref(obj);
 
             VIR_DELETE_ELEMENT(nets->objs, i, nets->count);
         } else {
-            virNetworkObjUnlock(obj);
+            virObjectUnlock(obj);
             i++;
         }
     }
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 3575659..1423676 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -258,7 +258,7 @@ struct _virNetworkDef {
 typedef struct _virNetworkObj virNetworkObj;
 typedef virNetworkObj *virNetworkObjPtr;
 struct _virNetworkObj {
-    virMutex lock;
+    virObjectLockable parent;
 
     pid_t dnsmasqPid;
     pid_t radvdPid;
@@ -275,6 +275,8 @@ struct _virNetworkObj {
     unsigned int taint;
 };
 
+virNetworkObjPtr virNetworkObjNew(void);
+
 typedef struct _virNetworkObjList virNetworkObjList;
 typedef virNetworkObjList *virNetworkObjListPtr;
 
@@ -305,7 +307,6 @@ bool virNetworkObjTaint(virNetworkObjPtr obj,
                         virNetworkTaintFlags taint);
 
 void virNetworkDefFree(virNetworkDefPtr def);
-void virNetworkObjFree(virNetworkObjPtr net);
 
 typedef bool (*virNetworkObjListFilter)(virConnectPtr conn,
                                         virNetworkDefPtr def);
@@ -412,9 +413,6 @@ int virNetworkObjIsDuplicate(virNetworkObjListPtr nets,
                              virNetworkDefPtr def,
                              bool check_active);
 
-void virNetworkObjLock(virNetworkObjPtr obj);
-void virNetworkObjUnlock(virNetworkObjPtr obj);
-
 VIR_ENUM_DECL(virNetworkForward)
 
 # define VIR_CONNECT_LIST_NETWORKS_FILTERS_ACTIVE   \
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index e2b558f..5dae05d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -565,7 +565,6 @@ virNetworkLoadAllState;
 virNetworkObjAssignDef;
 virNetworkObjFindByName;
 virNetworkObjFindByUUID;
-virNetworkObjFree;
 virNetworkObjGetPersistentDef;
 virNetworkObjIsDuplicate;
 virNetworkObjListExport;
@@ -574,11 +573,10 @@ virNetworkObjListGetNames;
 virNetworkObjListNew;
 virNetworkObjListNumOfNetworks;
 virNetworkObjListPrune;
-virNetworkObjLock;
+virNetworkObjNew;
 virNetworkObjReplacePersistentDef;
 virNetworkObjSetDefTransient;
 virNetworkObjTaint;
-virNetworkObjUnlock;
 virNetworkObjUnsetDefTransient;
 virNetworkObjUpdate;
 virNetworkRemoveInactive;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 9637371..51df46d 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -348,9 +348,9 @@ networkUpdateState(virNetworkObjPtr obj,
 {
     int ret = -1;
 
-    virNetworkObjLock(obj);
+    virObjectLock(obj);
     if (!virNetworkObjIsActive(obj)) {
-        virNetworkObjUnlock(obj);
+        virObjectUnlock(obj);
         return 0;
     }
 
@@ -403,7 +403,7 @@ networkUpdateState(virNetworkObjPtr obj,
 
     ret = 0;
  cleanup:
-    virNetworkObjUnlock(obj);
+    virObjectUnlock(obj);
     return ret;
 }
 
@@ -413,7 +413,7 @@ networkAutostartConfig(virNetworkObjPtr net,
 {
     int ret = -1;
 
-    virNetworkObjLock(net);
+    virObjectLock(net);
     if (net->autostart &&
         !virNetworkObjIsActive(net) &&
         networkStartNetwork(net) < 0)
@@ -421,7 +421,7 @@ networkAutostartConfig(virNetworkObjPtr net,
 
     ret = 0;
  cleanup:
-    virNetworkObjUnlock(net);
+    virObjectUnlock(net);
     return ret;
 }
 
@@ -1745,7 +1745,7 @@ networkRefreshDaemonsHelper(virNetworkObjPtr net,
                             void *opaque ATTRIBUTE_UNUSED)
 {
 
-    virNetworkObjLock(net);
+    virObjectLock(net);
     if (virNetworkObjIsActive(net) &&
         ((net->def->forward.type == VIR_NETWORK_FORWARD_NONE) ||
          (net->def->forward.type == VIR_NETWORK_FORWARD_NAT) ||
@@ -1759,7 +1759,7 @@ networkRefreshDaemonsHelper(virNetworkObjPtr net,
         networkRefreshDhcpDaemon(net);
         networkRefreshRadvd(net);
     }
-    virNetworkObjUnlock(net);
+    virObjectUnlock(net);
     return 0;
 }
 
@@ -1780,7 +1780,7 @@ networkReloadFirewallRulesHelper(virNetworkObjPtr net,
                                  void *opaque ATTRIBUTE_UNUSED)
 {
 
-    virNetworkObjLock(net);
+    virObjectLock(net);
     if (virNetworkObjIsActive(net) &&
         ((net->def->forward.type == VIR_NETWORK_FORWARD_NONE) ||
          (net->def->forward.type == VIR_NETWORK_FORWARD_NAT) ||
@@ -1793,7 +1793,7 @@ networkReloadFirewallRulesHelper(virNetworkObjPtr net,
             /* failed to add but already logged */
         }
     }
-    virNetworkObjUnlock(net);
+    virObjectUnlock(net);
     return 0;
 }
 
@@ -2497,7 +2497,7 @@ static virNetworkPtr networkLookupByUUID(virConnectPtr conn,
 
  cleanup:
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     return ret;
 }
 
@@ -2523,7 +2523,7 @@ static virNetworkPtr networkLookupByName(virConnectPtr conn,
 
  cleanup:
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     return ret;
 }
 
@@ -2671,7 +2671,7 @@ static int networkIsActive(virNetworkPtr net)
 
  cleanup:
     if (obj)
-        virNetworkObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -2690,7 +2690,7 @@ static int networkIsPersistent(virNetworkPtr net)
 
  cleanup:
     if (obj)
-        virNetworkObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -2960,7 +2960,7 @@ static virNetworkPtr networkCreateXML(virConnectPtr conn, const char *xml)
     if (event)
         virObjectEventStateQueue(driver->networkEventState, event);
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     networkDriverUnlock();
     return ret;
 }
@@ -3017,7 +3017,7 @@ static virNetworkPtr networkDefineXML(virConnectPtr conn, const char *xml)
     if (freeDef)
         virNetworkDefFree(def);
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     networkDriverUnlock();
     return ret;
 }
@@ -3078,7 +3078,7 @@ networkUndefine(virNetworkPtr net)
     if (event)
         virObjectEventStateQueue(driver->networkEventState, event);
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     networkDriverUnlock();
     return ret;
 }
@@ -3250,7 +3250,7 @@ networkUpdate(virNetworkPtr net,
     ret = 0;
  cleanup:
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     networkDriverUnlock();
     return ret;
 }
@@ -3285,7 +3285,7 @@ static int networkCreate(virNetworkPtr net)
     if (event)
         virObjectEventStateQueue(driver->networkEventState, event);
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     networkDriverUnlock();
     return ret;
 }
@@ -3336,7 +3336,7 @@ static int networkDestroy(virNetworkPtr net)
     if (event)
         virObjectEventStateQueue(driver->networkEventState, event);
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     networkDriverUnlock();
     return ret;
 }
@@ -3365,7 +3365,7 @@ static char *networkGetXMLDesc(virNetworkPtr net,
 
  cleanup:
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     return ret;
 }
 
@@ -3390,7 +3390,7 @@ static char *networkGetBridgeName(virNetworkPtr net) {
 
  cleanup:
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     return bridge;
 }
 
@@ -3411,7 +3411,7 @@ static int networkGetAutostart(virNetworkPtr net,
 
  cleanup:
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     return ret;
 }
 
@@ -3479,7 +3479,7 @@ static int networkSetAutostart(virNetworkPtr net,
     VIR_FREE(configFile);
     VIR_FREE(autostartLink);
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     networkDriverUnlock();
     return ret;
 }
@@ -3652,7 +3652,7 @@ networkGetDHCPLeases(virNetworkPtr network,
     virJSONValueFree(leases_array);
 
     if (obj)
-        virNetworkObjUnlock(obj);
+        virObjectUnlock(obj);
 
     return rv;
 
@@ -4125,7 +4125,7 @@ networkAllocateActualDevice(virDomainDefPtr dom,
 
  cleanup:
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     return ret;
 
  error:
@@ -4328,7 +4328,7 @@ networkNotifyActualDevice(virDomainDefPtr dom,
     ret = 0;
  cleanup:
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     return ret;
 
  error:
@@ -4478,7 +4478,7 @@ networkReleaseActualDevice(virDomainDefPtr dom,
     ret = 0;
  cleanup:
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
         virDomainActualNetDefFree(iface->data.network.actual);
         iface->data.network.actual = NULL;
@@ -4582,7 +4582,7 @@ networkGetNetworkAddress(const char *netname, char **netaddr)
     ret = 0;
  cleanup:
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     return ret;
 }
 
diff --git a/src/parallels/parallels_network.c b/src/parallels/parallels_network.c
index 62ed268..86038bf 100644
--- a/src/parallels/parallels_network.c
+++ b/src/parallels/parallels_network.c
@@ -230,7 +230,7 @@ parallelsLoadNetwork(parallelsConnPtr privconn, virJSONValuePtr jobj)
         goto cleanup;
     net->active = 1;
     net->autostart = 1;
-    virNetworkObjUnlock(net);
+    virObjectUnlock(net);
     return net;
 
  cleanup:
@@ -265,7 +265,7 @@ parallelsAddRoutedNetwork(parallelsConnPtr privconn)
     }
     net->active = 1;
     net->autostart = 1;
-    virNetworkObjUnlock(net);
+    virObjectUnlock(net);
 
     return net;
 
@@ -445,7 +445,7 @@ static virNetworkPtr parallelsNetworkLookupByUUID(virConnectPtr conn,
 
  cleanup:
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     return ret;
 }
 
@@ -469,7 +469,7 @@ static virNetworkPtr parallelsNetworkLookupByName(virConnectPtr conn,
 
  cleanup:
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     return ret;
 }
 
@@ -496,7 +496,7 @@ static char *parallelsNetworkGetXMLDesc(virNetworkPtr net,
 
  cleanup:
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     return ret;
 }
 
@@ -517,7 +517,7 @@ static int parallelsNetworkIsActive(virNetworkPtr net)
 
  cleanup:
     if (obj)
-        virNetworkObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -538,7 +538,7 @@ static int parallelsNetworkIsPersistent(virNetworkPtr net)
 
  cleanup:
     if (obj)
-        virNetworkObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -563,7 +563,7 @@ static int parallelsNetworkGetAutostart(virNetworkPtr net,
 
  cleanup:
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     return ret;
 }
 
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 693b930..20c77de 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -787,7 +787,7 @@ testOpenDefault(virConnectPtr conn)
         goto error;
     }
     netobj->active = 1;
-    virNetworkObjUnlock(netobj);
+    virObjectUnlock(netobj);
 
     if (!(interfacedef = virInterfaceDefParseString(defaultInterfaceXML)))
         goto error;
@@ -1155,7 +1155,7 @@ testParseNetworks(testConnPtr privconn,
         }
 
         obj->active = 1;
-        virNetworkObjUnlock(obj);
+        virObjectUnlock(obj);
     }
 
     ret = 0;
@@ -3508,7 +3508,7 @@ static virNetworkPtr testNetworkLookupByUUID(virConnectPtr conn,
 
  cleanup:
     if (net)
-        virNetworkObjUnlock(net);
+        virObjectUnlock(net);
     return ret;
 }
 
@@ -3532,7 +3532,7 @@ static virNetworkPtr testNetworkLookupByName(virConnectPtr conn,
 
  cleanup:
     if (net)
-        virNetworkObjUnlock(net);
+        virObjectUnlock(net);
     return ret;
 }
 
@@ -3621,7 +3621,7 @@ static int testNetworkIsActive(virNetworkPtr net)
 
  cleanup:
     if (obj)
-        virNetworkObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -3642,7 +3642,7 @@ static int testNetworkIsPersistent(virNetworkPtr net)
 
  cleanup:
     if (obj)
-        virNetworkObjUnlock(obj);
+        virObjectUnlock(obj);
     return ret;
 }
 
@@ -3675,7 +3675,7 @@ static virNetworkPtr testNetworkCreateXML(virConnectPtr conn, const char *xml)
     if (event)
         testObjectEventQueue(privconn, event);
     if (net)
-        virNetworkObjUnlock(net);
+        virObjectUnlock(net);
     testDriverUnlock(privconn);
     return ret;
 }
@@ -3708,7 +3708,7 @@ virNetworkPtr testNetworkDefineXML(virConnectPtr conn, const char *xml)
     if (event)
         testObjectEventQueue(privconn, event);
     if (net)
-        virNetworkObjUnlock(net);
+        virObjectUnlock(net);
     testDriverUnlock(privconn);
     return ret;
 }
@@ -3746,7 +3746,7 @@ static int testNetworkUndefine(virNetworkPtr network)
     if (event)
         testObjectEventQueue(privconn, event);
     if (privnet)
-        virNetworkObjUnlock(privnet);
+        virObjectUnlock(privnet);
     testDriverUnlock(privconn);
     return ret;
 }
@@ -3796,7 +3796,7 @@ testNetworkUpdate(virNetworkPtr net,
     ret = 0;
  cleanup:
     if (network)
-        virNetworkObjUnlock(network);
+        virObjectUnlock(network);
     testDriverUnlock(privconn);
     return ret;
 }
@@ -3833,7 +3833,7 @@ static int testNetworkCreate(virNetworkPtr network)
     if (event)
         testObjectEventQueue(privconn, event);
     if (privnet)
-        virNetworkObjUnlock(privnet);
+        virObjectUnlock(privnet);
     return ret;
 }
 
@@ -3866,7 +3866,7 @@ static int testNetworkDestroy(virNetworkPtr network)
     if (event)
         testObjectEventQueue(privconn, event);
     if (privnet)
-        virNetworkObjUnlock(privnet);
+        virObjectUnlock(privnet);
     testDriverUnlock(privconn);
     return ret;
 }
@@ -3893,7 +3893,7 @@ static char *testNetworkGetXMLDesc(virNetworkPtr network,
 
  cleanup:
     if (privnet)
-        virNetworkObjUnlock(privnet);
+        virObjectUnlock(privnet);
     return ret;
 }
 
@@ -3922,7 +3922,7 @@ static char *testNetworkGetBridgeName(virNetworkPtr network) {
 
  cleanup:
     if (privnet)
-        virNetworkObjUnlock(privnet);
+        virObjectUnlock(privnet);
     return bridge;
 }
 
@@ -3947,7 +3947,7 @@ static int testNetworkGetAutostart(virNetworkPtr network,
 
  cleanup:
     if (privnet)
-        virNetworkObjUnlock(privnet);
+        virObjectUnlock(privnet);
     return ret;
 }
 
@@ -3972,7 +3972,7 @@ static int testNetworkSetAutostart(virNetworkPtr network,
 
  cleanup:
     if (privnet)
-        virNetworkObjUnlock(privnet);
+        virObjectUnlock(privnet);
     return ret;
 }
 
diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c
index 280db30..6df161f 100644
--- a/tests/networkxml2conftest.c
+++ b/tests/networkxml2conftest.c
@@ -40,7 +40,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr
     if (!(dev = virNetworkDefParseString(inXmlData)))
         goto fail;
 
-    if (VIR_ALLOC(obj) < 0)
+    if (!(obj = virNetworkObjNew()))
         goto fail;
 
     obj->def = dev;
@@ -66,7 +66,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr
     VIR_FREE(actual);
     VIR_FREE(pidfile);
     virCommandFree(cmd);
-    virNetworkObjFree(obj);
+    virObjectUnref(obj);
     dnsmasqContextFree(dctx);
     return ret;
 }
diff --git a/tests/objectlocking.ml b/tests/objectlocking.ml
index 7826148..fd83d6d 100644
--- a/tests/objectlocking.ml
+++ b/tests/objectlocking.ml
@@ -84,7 +84,6 @@ let lockedObjMethods = [
  *)
 let objectLockMethods = [
    "virDomainObjLock";
-   "virNetworkObjLock";
    "virStoragePoolObjLock";
    "virNodeDevObjLock"
 ]
@@ -99,7 +98,6 @@ let objectLockMethods = [
  *)
 let objectUnlockMethods = [
    "virDomainObjUnlock";
-   "virNetworkObjUnlock";
    "virStoragePoolObjUnlock";
    "virNodeDevObjUnlock"
 ]
-- 
2.0.5

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