[PATCH v1 09/31] parallels: s/virNetworkObjList/virNetworkObjListPtr/

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

 



In order to hide the object internals (and use just accessors
everywhere), lets store a pointer to the object, instead of object
itself.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/parallels/parallels_driver.c  |  5 +++-
 src/parallels/parallels_network.c | 60 +++++++++++++++++++--------------------
 src/parallels/parallels_utils.h   |  2 +-
 3 files changed, 35 insertions(+), 32 deletions(-)

diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index c9338b5..32f2ede 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -207,7 +207,8 @@ parallelsOpenDefault(virConnectPtr conn)
                                                  NULL, NULL)))
         goto error;
 
-    if (!(privconn->domains = virDomainObjListNew()))
+    if (!(privconn->domains = virDomainObjListNew()) ||
+        VIR_ALLOC(privconn->networks) < 0)
         goto error;
 
     if (!(privconn->domainEventState = virObjectEventStateNew()))
@@ -225,6 +226,7 @@ parallelsOpenDefault(virConnectPtr conn)
 
  error:
     virObjectUnref(privconn->domains);
+    VIR_FREE(privconn->networks);
     virObjectUnref(privconn->caps);
     virStoragePoolObjListFree(&privconn->pools);
     virObjectEventStateFree(privconn->domainEventState);
@@ -283,6 +285,7 @@ parallelsConnectClose(virConnectPtr conn)
     virObjectUnref(privconn->caps);
     virObjectUnref(privconn->xmlopt);
     virObjectUnref(privconn->domains);
+    VIR_FREE(privconn->networks);
     virObjectEventStateFree(privconn->domainEventState);
     prlsdkDisconnect(privconn);
     conn->privateData = NULL;
diff --git a/src/parallels/parallels_network.c b/src/parallels/parallels_network.c
index 960bd50..bfa7432 100644
--- a/src/parallels/parallels_network.c
+++ b/src/parallels/parallels_network.c
@@ -226,7 +226,7 @@ parallelsLoadNetwork(parallelsConnPtr privconn, virJSONValuePtr jobj)
         goto cleanup;
     }
 
-    if (!(net = virNetworkAssignDef(&privconn->networks, def, false)))
+    if (!(net = virNetworkAssignDef(privconn->networks, def, false)))
         goto cleanup;
     net->active = 1;
     net->autostart = 1;
@@ -259,7 +259,7 @@ parallelsAddRoutedNetwork(parallelsConnPtr privconn)
     }
     def->uuid_specified = 1;
 
-    if (!(net = virNetworkAssignDef(&privconn->networks, def, false))) {
+    if (!(net = virNetworkAssignDef(privconn->networks, def, false))) {
         virNetworkDefFree(def);
         goto cleanup;
     }
@@ -337,7 +337,7 @@ int parallelsNetworkClose(virConnectPtr conn)
 {
     parallelsConnPtr privconn = conn->privateData;
     parallelsDriverLock(privconn);
-    virNetworkObjListFree(&privconn->networks);
+    virNetworkObjListFree(privconn->networks);
     parallelsDriverUnlock(privconn);
     return 0;
 }
@@ -349,11 +349,11 @@ static int parallelsConnectNumOfNetworks(virConnectPtr conn)
     parallelsConnPtr privconn = conn->privateData;
 
     parallelsDriverLock(privconn);
-    for (i = 0; i < privconn->networks.count; i++) {
-        virNetworkObjLock(privconn->networks.objs[i]);
-        if (virNetworkObjIsActive(privconn->networks.objs[i]))
+    for (i = 0; i < privconn->networks->count; i++) {
+        virNetworkObjLock(privconn->networks->objs[i]);
+        if (virNetworkObjIsActive(privconn->networks->objs[i]))
             nactive++;
-        virNetworkObjUnlock(privconn->networks.objs[i]);
+        virNetworkObjUnlock(privconn->networks->objs[i]);
     }
     parallelsDriverUnlock(privconn);
 
@@ -369,16 +369,16 @@ static int parallelsConnectListNetworks(virConnectPtr conn,
     size_t i;
 
     parallelsDriverLock(privconn);
-    for (i = 0; i < privconn->networks.count && got < nnames; i++) {
-        virNetworkObjLock(privconn->networks.objs[i]);
-        if (virNetworkObjIsActive(privconn->networks.objs[i])) {
-            if (VIR_STRDUP(names[got], privconn->networks.objs[i]->def->name) < 0) {
-                virNetworkObjUnlock(privconn->networks.objs[i]);
+    for (i = 0; i < privconn->networks->count && got < nnames; i++) {
+        virNetworkObjLock(privconn->networks->objs[i]);
+        if (virNetworkObjIsActive(privconn->networks->objs[i])) {
+            if (VIR_STRDUP(names[got], privconn->networks->objs[i]->def->name) < 0) {
+                virNetworkObjUnlock(privconn->networks->objs[i]);
                 goto cleanup;
             }
             got++;
         }
-        virNetworkObjUnlock(privconn->networks.objs[i]);
+        virNetworkObjUnlock(privconn->networks->objs[i]);
     }
     parallelsDriverUnlock(privconn);
 
@@ -398,11 +398,11 @@ static int parallelsConnectNumOfDefinedNetworks(virConnectPtr conn)
     parallelsConnPtr privconn = conn->privateData;
 
     parallelsDriverLock(privconn);
-    for (i = 0; i < privconn->networks.count; i++) {
-        virNetworkObjLock(privconn->networks.objs[i]);
-        if (!virNetworkObjIsActive(privconn->networks.objs[i]))
+    for (i = 0; i < privconn->networks->count; i++) {
+        virNetworkObjLock(privconn->networks->objs[i]);
+        if (!virNetworkObjIsActive(privconn->networks->objs[i]))
             ninactive++;
-        virNetworkObjUnlock(privconn->networks.objs[i]);
+        virNetworkObjUnlock(privconn->networks->objs[i]);
     }
     parallelsDriverUnlock(privconn);
 
@@ -418,16 +418,16 @@ static int parallelsConnectListDefinedNetworks(virConnectPtr conn,
     size_t i;
 
     parallelsDriverLock(privconn);
-    for (i = 0; i < privconn->networks.count && got < nnames; i++) {
-        virNetworkObjLock(privconn->networks.objs[i]);
-        if (!virNetworkObjIsActive(privconn->networks.objs[i])) {
-            if (VIR_STRDUP(names[got], privconn->networks.objs[i]->def->name) < 0) {
-                virNetworkObjUnlock(privconn->networks.objs[i]);
+    for (i = 0; i < privconn->networks->count && got < nnames; i++) {
+        virNetworkObjLock(privconn->networks->objs[i]);
+        if (!virNetworkObjIsActive(privconn->networks->objs[i])) {
+            if (VIR_STRDUP(names[got], privconn->networks->objs[i]->def->name) < 0) {
+                virNetworkObjUnlock(privconn->networks->objs[i]);
                 goto cleanup;
             }
             got++;
         }
-        virNetworkObjUnlock(privconn->networks.objs[i]);
+        virNetworkObjUnlock(privconn->networks->objs[i]);
     }
     parallelsDriverUnlock(privconn);
     return got;
@@ -449,7 +449,7 @@ static int parallelsConnectListAllNetworks(virConnectPtr conn,
     virCheckFlags(VIR_CONNECT_LIST_NETWORKS_FILTERS_ALL, -1);
 
     parallelsDriverLock(privconn);
-    ret = virNetworkObjListExport(conn, &privconn->networks, nets, NULL, flags);
+    ret = virNetworkObjListExport(conn, privconn->networks, nets, NULL, flags);
     parallelsDriverUnlock(privconn);
 
     return ret;
@@ -463,7 +463,7 @@ static virNetworkPtr parallelsNetworkLookupByUUID(virConnectPtr conn,
     virNetworkPtr ret = NULL;
 
     parallelsDriverLock(privconn);
-    network = virNetworkFindByUUID(&privconn->networks, uuid);
+    network = virNetworkFindByUUID(privconn->networks, uuid);
     parallelsDriverUnlock(privconn);
     if (!network) {
         virReportError(VIR_ERR_NO_NETWORK,
@@ -487,7 +487,7 @@ static virNetworkPtr parallelsNetworkLookupByName(virConnectPtr conn,
     virNetworkPtr ret = NULL;
 
     parallelsDriverLock(privconn);
-    network = virNetworkFindByName(&privconn->networks, name);
+    network = virNetworkFindByName(privconn->networks, name);
     parallelsDriverUnlock(privconn);
     if (!network) {
         virReportError(VIR_ERR_NO_NETWORK,
@@ -513,7 +513,7 @@ static char *parallelsNetworkGetXMLDesc(virNetworkPtr net,
     virCheckFlags(VIR_NETWORK_XML_INACTIVE, NULL);
 
     parallelsDriverLock(privconn);
-    network = virNetworkFindByUUID(&privconn->networks, net->uuid);
+    network = virNetworkFindByUUID(privconn->networks, net->uuid);
     parallelsDriverUnlock(privconn);
 
     if (!network) {
@@ -537,7 +537,7 @@ static int parallelsNetworkIsActive(virNetworkPtr net)
     int ret = -1;
 
     parallelsDriverLock(privconn);
-    obj = virNetworkFindByUUID(&privconn->networks, net->uuid);
+    obj = virNetworkFindByUUID(privconn->networks, net->uuid);
     parallelsDriverUnlock(privconn);
     if (!obj) {
         virReportError(VIR_ERR_NO_NETWORK, NULL);
@@ -558,7 +558,7 @@ static int parallelsNetworkIsPersistent(virNetworkPtr net)
     int ret = -1;
 
     parallelsDriverLock(privconn);
-    obj = virNetworkFindByUUID(&privconn->networks, net->uuid);
+    obj = virNetworkFindByUUID(privconn->networks, net->uuid);
     parallelsDriverUnlock(privconn);
     if (!obj) {
         virReportError(VIR_ERR_NO_NETWORK, NULL);
@@ -580,7 +580,7 @@ static int parallelsNetworkGetAutostart(virNetworkPtr net,
     int ret = -1;
 
     parallelsDriverLock(privconn);
-    network = virNetworkFindByUUID(&privconn->networks, net->uuid);
+    network = virNetworkFindByUUID(privconn->networks, net->uuid);
     parallelsDriverUnlock(privconn);
     if (!network) {
         virReportError(VIR_ERR_NO_NETWORK,
diff --git a/src/parallels/parallels_utils.h b/src/parallels/parallels_utils.h
index bebf841..ead5586 100644
--- a/src/parallels/parallels_utils.h
+++ b/src/parallels/parallels_utils.h
@@ -55,7 +55,7 @@ struct _parallelsConn {
     PRL_HANDLE server;
     PRL_UINT32 jobTimeout;
     virStoragePoolObjList pools;
-    virNetworkObjList networks;
+    virNetworkObjListPtr networks;
     virCapsPtr caps;
     virDomainXMLOptionPtr xmlopt;
     virObjectEventStatePtr domainEventState;
-- 
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]