[PATCH v2 13/24] bridge_driver: Use virNetworkObjEndAPI

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

 



So far, this is pure code replacement. But once we introduce
reference counting to virNetworkObj this will be more handy as
there'll be only one function to change: virNetworkObjEndAPI().

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/network/bridge_driver.c | 57 +++++++++++++++------------------------------
 1 file changed, 19 insertions(+), 38 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 51df46d..8501603 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2496,8 +2496,7 @@ static virNetworkPtr networkLookupByUUID(virConnectPtr conn,
     ret = virGetNetwork(conn, network->def->name, network->def->uuid);
 
  cleanup:
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     return ret;
 }
 
@@ -2522,8 +2521,7 @@ static virNetworkPtr networkLookupByName(virConnectPtr conn,
     ret = virGetNetwork(conn, network->def->name, network->def->uuid);
 
  cleanup:
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     return ret;
 }
 
@@ -2670,8 +2668,7 @@ static int networkIsActive(virNetworkPtr net)
     ret = virNetworkObjIsActive(obj);
 
  cleanup:
-    if (obj)
-        virObjectUnlock(obj);
+    virNetworkObjEndAPI(&obj);
     return ret;
 }
 
@@ -2689,8 +2686,7 @@ static int networkIsPersistent(virNetworkPtr net)
     ret = obj->persistent;
 
  cleanup:
-    if (obj)
-        virObjectUnlock(obj);
+    virNetworkObjEndAPI(&obj);
     return ret;
 }
 
@@ -2959,8 +2955,7 @@ static virNetworkPtr networkCreateXML(virConnectPtr conn, const char *xml)
     virNetworkDefFree(def);
     if (event)
         virObjectEventStateQueue(driver->networkEventState, event);
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     networkDriverUnlock();
     return ret;
 }
@@ -3016,8 +3011,7 @@ static virNetworkPtr networkDefineXML(virConnectPtr conn, const char *xml)
         virObjectEventStateQueue(driver->networkEventState, event);
     if (freeDef)
         virNetworkDefFree(def);
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     networkDriverUnlock();
     return ret;
 }
@@ -3077,8 +3071,7 @@ networkUndefine(virNetworkPtr net)
  cleanup:
     if (event)
         virObjectEventStateQueue(driver->networkEventState, event);
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     networkDriverUnlock();
     return ret;
 }
@@ -3249,8 +3242,7 @@ networkUpdate(virNetworkPtr net,
     }
     ret = 0;
  cleanup:
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     networkDriverUnlock();
     return ret;
 }
@@ -3284,8 +3276,7 @@ static int networkCreate(virNetworkPtr net)
  cleanup:
     if (event)
         virObjectEventStateQueue(driver->networkEventState, event);
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     networkDriverUnlock();
     return ret;
 }
@@ -3335,8 +3326,7 @@ static int networkDestroy(virNetworkPtr net)
  cleanup:
     if (event)
         virObjectEventStateQueue(driver->networkEventState, event);
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     networkDriverUnlock();
     return ret;
 }
@@ -3364,8 +3354,7 @@ static char *networkGetXMLDesc(virNetworkPtr net,
     ret = virNetworkDefFormat(def, flags);
 
  cleanup:
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     return ret;
 }
 
@@ -3389,8 +3378,7 @@ static char *networkGetBridgeName(virNetworkPtr net) {
     ignore_value(VIR_STRDUP(bridge, network->def->bridge));
 
  cleanup:
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     return bridge;
 }
 
@@ -3410,8 +3398,7 @@ static int networkGetAutostart(virNetworkPtr net,
     ret = 0;
 
  cleanup:
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     return ret;
 }
 
@@ -3478,8 +3465,7 @@ static int networkSetAutostart(virNetworkPtr net,
  cleanup:
     VIR_FREE(configFile);
     VIR_FREE(autostartLink);
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     networkDriverUnlock();
     return ret;
 }
@@ -3651,8 +3637,7 @@ networkGetDHCPLeases(virNetworkPtr network,
     VIR_FREE(custom_lease_file);
     virJSONValueFree(leases_array);
 
-    if (obj)
-        virObjectUnlock(obj);
+    virNetworkObjEndAPI(&obj);
 
     return rv;
 
@@ -4124,8 +4109,7 @@ networkAllocateActualDevice(virDomainDefPtr dom,
     ret = 0;
 
  cleanup:
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     return ret;
 
  error:
@@ -4327,8 +4311,7 @@ networkNotifyActualDevice(virDomainDefPtr dom,
 
     ret = 0;
  cleanup:
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     return ret;
 
  error:
@@ -4477,8 +4460,7 @@ networkReleaseActualDevice(virDomainDefPtr dom,
     }
     ret = 0;
  cleanup:
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
         virDomainActualNetDefFree(iface->data.network.actual);
         iface->data.network.actual = NULL;
@@ -4581,8 +4563,7 @@ networkGetNetworkAddress(const char *netname, char **netaddr)
 
     ret = 0;
  cleanup:
-    if (network)
-        virObjectUnlock(network);
+    virNetworkObjEndAPI(&network);
     return ret;
 }
 
-- 
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]