
On Thu, Feb 26, 2015 at 15:17:18 +0100, Michal Privoznik wrote:
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@redhat.com> --- 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)
This is a bit confusing. The network object is allocated in the VM driver open function ...
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);
And deleted in the VM driver ...
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);
But is cleared in the network subdriver clenup function.
parallelsDriverUnlock(privconn); return 0; }
I think it should be put into parallelsNetworkOpen. Peter