mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-14 23:24:23 +03:00
test: Extract code to free testDriver into testDriverFree
Avoid reimplementing it 3 times.
This commit is contained in:
parent
c54cfc4505
commit
8b43335abb
@ -135,6 +135,26 @@ static const virNodeInfo defaultNodeInfo = {
|
|||||||
2,
|
2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
testDriverFree(testDriverPtr driver)
|
||||||
|
{
|
||||||
|
if (!driver)
|
||||||
|
return;
|
||||||
|
|
||||||
|
virObjectUnref(driver->caps);
|
||||||
|
virObjectUnref(driver->xmlopt);
|
||||||
|
virObjectUnref(driver->domains);
|
||||||
|
virNodeDeviceObjListFree(&driver->devs);
|
||||||
|
virObjectUnref(driver->networks);
|
||||||
|
virInterfaceObjListFree(&driver->ifaces);
|
||||||
|
virStoragePoolObjListFree(&driver->pools);
|
||||||
|
virObjectEventStateFree(driver->eventState);
|
||||||
|
VIR_FREE(driver->path);
|
||||||
|
virMutexUnlock(&driver->lock);
|
||||||
|
virMutexDestroy(&driver->lock);
|
||||||
|
|
||||||
|
VIR_FREE(driver);
|
||||||
|
}
|
||||||
|
|
||||||
static void testObjectEventQueue(testDriverPtr driver,
|
static void testObjectEventQueue(testDriverPtr driver,
|
||||||
virObjectEventPtr event);
|
virObjectEventPtr event);
|
||||||
@ -830,16 +850,7 @@ testOpenDefault(virConnectPtr conn)
|
|||||||
return VIR_DRV_OPEN_SUCCESS;
|
return VIR_DRV_OPEN_SUCCESS;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (privconn) {
|
testDriverFree(privconn);
|
||||||
virObjectUnref(privconn->domains);
|
|
||||||
virObjectUnref(privconn->networks);
|
|
||||||
virInterfaceObjListFree(&privconn->ifaces);
|
|
||||||
virStoragePoolObjListFree(&privconn->pools);
|
|
||||||
virNodeDeviceObjListFree(&privconn->devs);
|
|
||||||
virObjectUnref(privconn->caps);
|
|
||||||
virObjectEventStateFree(privconn->eventState);
|
|
||||||
virMutexDestroy(&privconn->lock);
|
|
||||||
}
|
|
||||||
conn->privateData = NULL;
|
conn->privateData = NULL;
|
||||||
virDomainDefFree(domdef);
|
virDomainDefFree(domdef);
|
||||||
defaultConnections--;
|
defaultConnections--;
|
||||||
@ -1465,14 +1476,7 @@ testOpenFromFile(virConnectPtr conn, const char *file)
|
|||||||
error:
|
error:
|
||||||
xmlXPathFreeContext(ctxt);
|
xmlXPathFreeContext(ctxt);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
virObjectUnref(privconn->domains);
|
testDriverFree(privconn);
|
||||||
virObjectUnref(privconn->networks);
|
|
||||||
virInterfaceObjListFree(&privconn->ifaces);
|
|
||||||
virStoragePoolObjListFree(&privconn->pools);
|
|
||||||
VIR_FREE(privconn->path);
|
|
||||||
virObjectEventStateFree(privconn->eventState);
|
|
||||||
testDriverUnlock(privconn);
|
|
||||||
VIR_FREE(privconn);
|
|
||||||
conn->privateData = NULL;
|
conn->privateData = NULL;
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
}
|
}
|
||||||
@ -1590,20 +1594,7 @@ static int testConnectClose(virConnectPtr conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
testDriverLock(privconn);
|
testDriverLock(privconn);
|
||||||
virObjectUnref(privconn->caps);
|
testDriverFree(privconn);
|
||||||
virObjectUnref(privconn->xmlopt);
|
|
||||||
virObjectUnref(privconn->domains);
|
|
||||||
virNodeDeviceObjListFree(&privconn->devs);
|
|
||||||
virObjectUnref(privconn->networks);
|
|
||||||
virInterfaceObjListFree(&privconn->ifaces);
|
|
||||||
virStoragePoolObjListFree(&privconn->pools);
|
|
||||||
virObjectEventStateFree(privconn->eventState);
|
|
||||||
VIR_FREE(privconn->path);
|
|
||||||
|
|
||||||
testDriverUnlock(privconn);
|
|
||||||
virMutexDestroy(&privconn->lock);
|
|
||||||
|
|
||||||
VIR_FREE(privconn);
|
|
||||||
|
|
||||||
if (dflt) {
|
if (dflt) {
|
||||||
defaultConn = NULL;
|
defaultConn = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user