mirror of https://gitee.com/openkylin/libvirt.git
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 ||
|
if ((ret = parallelsOpenDefault(conn)) != VIR_DRV_OPEN_SUCCESS ||
|
||||||
(ret = parallelsStorageOpen(conn, flags)) != 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 ret;
|
||||||
|
}
|
||||||
|
|
||||||
return VIR_DRV_OPEN_SUCCESS;
|
return VIR_DRV_OPEN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -275,6 +277,9 @@ parallelsConnectClose(virConnectPtr conn)
|
||||||
{
|
{
|
||||||
parallelsConnPtr privconn = conn->privateData;
|
parallelsConnPtr privconn = conn->privateData;
|
||||||
|
|
||||||
|
if (!privconn)
|
||||||
|
return 0;
|
||||||
|
|
||||||
parallelsNetworkClose(conn);
|
parallelsNetworkClose(conn);
|
||||||
parallelsStorageClose(conn);
|
parallelsStorageClose(conn);
|
||||||
|
|
||||||
|
|
|
@ -344,6 +344,10 @@ parallelsNetworkOpen(virConnectPtr conn,
|
||||||
int parallelsNetworkClose(virConnectPtr conn)
|
int parallelsNetworkClose(virConnectPtr conn)
|
||||||
{
|
{
|
||||||
parallelsConnPtr privconn = conn->privateData;
|
parallelsConnPtr privconn = conn->privateData;
|
||||||
|
|
||||||
|
if (!privconn)
|
||||||
|
return 0;
|
||||||
|
|
||||||
parallelsDriverLock(privconn);
|
parallelsDriverLock(privconn);
|
||||||
virNetworkObjListFree(privconn->networks);
|
virNetworkObjListFree(privconn->networks);
|
||||||
VIR_FREE(privconn->networks);
|
VIR_FREE(privconn->networks);
|
||||||
|
|
|
@ -72,9 +72,15 @@ parallelsStorageClose(virConnectPtr conn)
|
||||||
{
|
{
|
||||||
parallelsConnPtr privconn = conn->privateData;
|
parallelsConnPtr privconn = conn->privateData;
|
||||||
|
|
||||||
|
if (!privconn)
|
||||||
|
return 0;
|
||||||
|
|
||||||
virStorageDriverStatePtr storageState = privconn->storageState;
|
virStorageDriverStatePtr storageState = privconn->storageState;
|
||||||
privconn->storageState = NULL;
|
privconn->storageState = NULL;
|
||||||
|
|
||||||
|
if (!storageState)
|
||||||
|
return 0;
|
||||||
|
|
||||||
parallelsStorageLock(storageState);
|
parallelsStorageLock(storageState);
|
||||||
virStoragePoolObjListFree(&privconn->pools);
|
virStoragePoolObjListFree(&privconn->pools);
|
||||||
VIR_FREE(storageState->configDir);
|
VIR_FREE(storageState->configDir);
|
||||||
|
|
Loading…
Reference in New Issue