mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
parallels: Cleanup partly opened drivers on connect open failure
Well, the parallelsConnectOpen() joins several sub-driver openings into one big if condition. If any of sub-driver fails to open, the whole API finishes immediately. The problem is, sub-drivers may have left some memory allocated. Fortunately, we have a free function for that: parallelsConnectClose(). This is, however, not prepared for partially allocated driver structure. So, prepare the free function for it and call it at the right place, in the if body. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
3fde7986d6
commit
6954e7da52
@ -264,8 +264,10 @@ parallelsConnectOpen(virConnectPtr conn,
|
||||
|
||||
if ((ret = parallelsOpenDefault(conn)) != VIR_DRV_OPEN_SUCCESS ||
|
||||
(ret = parallelsStorageOpen(conn, flags)) != VIR_DRV_OPEN_SUCCESS ||
|
||||
(ret = parallelsNetworkOpen(conn, flags)) != VIR_DRV_OPEN_SUCCESS)
|
||||
(ret = parallelsNetworkOpen(conn, flags)) != VIR_DRV_OPEN_SUCCESS) {
|
||||
parallelsConnectClose(conn);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return VIR_DRV_OPEN_SUCCESS;
|
||||
}
|
||||
@ -275,6 +277,9 @@ parallelsConnectClose(virConnectPtr conn)
|
||||
{
|
||||
parallelsConnPtr privconn = conn->privateData;
|
||||
|
||||
if (!privconn)
|
||||
return 0;
|
||||
|
||||
parallelsNetworkClose(conn);
|
||||
parallelsStorageClose(conn);
|
||||
|
||||
|
@ -344,6 +344,10 @@ parallelsNetworkOpen(virConnectPtr conn,
|
||||
int parallelsNetworkClose(virConnectPtr conn)
|
||||
{
|
||||
parallelsConnPtr privconn = conn->privateData;
|
||||
|
||||
if (!privconn)
|
||||
return 0;
|
||||
|
||||
parallelsDriverLock(privconn);
|
||||
virNetworkObjListFree(privconn->networks);
|
||||
VIR_FREE(privconn->networks);
|
||||
|
@ -72,9 +72,15 @@ parallelsStorageClose(virConnectPtr conn)
|
||||
{
|
||||
parallelsConnPtr privconn = conn->privateData;
|
||||
|
||||
if (!privconn)
|
||||
return 0;
|
||||
|
||||
virStorageDriverStatePtr storageState = privconn->storageState;
|
||||
privconn->storageState = NULL;
|
||||
|
||||
if (!storageState)
|
||||
return 0;
|
||||
|
||||
parallelsStorageLock(storageState);
|
||||
virStoragePoolObjListFree(&privconn->pools);
|
||||
VIR_FREE(storageState->configDir);
|
||||
|
Loading…
Reference in New Issue
Block a user