mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
test: Convert testDriver to virObjectLockable
The test driver state (@testDriver) uses it's own reference counting and locking implementation. Instead of doing that, convert @testDriver into a virObjectLockable and use the provided functionalities. Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
This commit is contained in:
parent
6aa75b9462
commit
794af564f4
@ -92,7 +92,7 @@ typedef struct _testAuth testAuth;
|
|||||||
typedef struct _testAuth *testAuthPtr;
|
typedef struct _testAuth *testAuthPtr;
|
||||||
|
|
||||||
struct _testDriver {
|
struct _testDriver {
|
||||||
virMutex lock;
|
virObjectLockable parent;
|
||||||
|
|
||||||
virNodeInfo nodeInfo;
|
virNodeInfo nodeInfo;
|
||||||
virInterfaceObjListPtr ifaces;
|
virInterfaceObjListPtr ifaces;
|
||||||
@ -124,9 +124,19 @@ typedef struct _testDriver testDriver;
|
|||||||
typedef testDriver *testDriverPtr;
|
typedef testDriver *testDriverPtr;
|
||||||
|
|
||||||
static testDriverPtr defaultPrivconn;
|
static testDriverPtr defaultPrivconn;
|
||||||
static int defaultConnections;
|
|
||||||
static virMutex defaultLock = VIR_MUTEX_INITIALIZER;
|
static virMutex defaultLock = VIR_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
|
static virClassPtr testDriverClass;
|
||||||
|
static void testDriverDispose(void *obj);
|
||||||
|
static int testDriverOnceInit(void)
|
||||||
|
{
|
||||||
|
if (!(VIR_CLASS_NEW(testDriver, virClassForObjectLockable())))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
VIR_ONCE_GLOBAL_INIT(testDriver)
|
||||||
|
|
||||||
#define TEST_MODEL "i686"
|
#define TEST_MODEL "i686"
|
||||||
#define TEST_EMULATOR "/usr/bin/test-hv"
|
#define TEST_EMULATOR "/usr/bin/test-hv"
|
||||||
|
|
||||||
@ -142,10 +152,9 @@ static const virNodeInfo defaultNodeInfo = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
testDriverFree(testDriverPtr driver)
|
testDriverDispose(void *obj)
|
||||||
{
|
{
|
||||||
if (!driver)
|
testDriverPtr driver = obj;
|
||||||
return;
|
|
||||||
|
|
||||||
virObjectUnref(driver->caps);
|
virObjectUnref(driver->caps);
|
||||||
virObjectUnref(driver->xmlopt);
|
virObjectUnref(driver->xmlopt);
|
||||||
@ -155,21 +164,6 @@ testDriverFree(testDriverPtr driver)
|
|||||||
virObjectUnref(driver->ifaces);
|
virObjectUnref(driver->ifaces);
|
||||||
virObjectUnref(driver->pools);
|
virObjectUnref(driver->pools);
|
||||||
virObjectUnref(driver->eventState);
|
virObjectUnref(driver->eventState);
|
||||||
virMutexUnlock(&driver->lock);
|
|
||||||
virMutexDestroy(&driver->lock);
|
|
||||||
|
|
||||||
VIR_FREE(driver);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void testDriverLock(testDriverPtr driver)
|
|
||||||
{
|
|
||||||
virMutexLock(&driver->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void testDriverUnlock(testDriverPtr driver)
|
|
||||||
{
|
|
||||||
virMutexUnlock(&driver->lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TEST_NAMESPACE_HREF "http://libvirt.org/schemas/domain/test/1.0"
|
#define TEST_NAMESPACE_HREF "http://libvirt.org/schemas/domain/test/1.0"
|
||||||
@ -401,14 +395,11 @@ testDriverNew(void)
|
|||||||
};
|
};
|
||||||
testDriverPtr ret;
|
testDriverPtr ret;
|
||||||
|
|
||||||
if (VIR_ALLOC(ret) < 0)
|
if (testDriverInitialize() < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (virMutexInit(&ret->lock) < 0) {
|
if (!(ret = virObjectLockableNew(testDriverClass)))
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
return NULL;
|
||||||
"%s", _("cannot initialize mutex"));
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(ret->xmlopt = virDomainXMLOptionNew(NULL, NULL, &ns, NULL, NULL)) ||
|
if (!(ret->xmlopt = virDomainXMLOptionNew(NULL, NULL, &ns, NULL, NULL)) ||
|
||||||
!(ret->eventState = virObjectEventStateNew()) ||
|
!(ret->eventState = virObjectEventStateNew()) ||
|
||||||
@ -424,7 +415,7 @@ testDriverNew(void)
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
testDriverFree(ret);
|
virObjectUnref(ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1256,7 +1247,7 @@ testOpenFromFile(virConnectPtr conn, const char *file)
|
|||||||
if (!(privconn = testDriverNew()))
|
if (!(privconn = testDriverNew()))
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
conn->privateData = privconn;
|
conn->privateData = privconn;
|
||||||
|
|
||||||
if (!(privconn->caps = testBuildCapabilities(conn)))
|
if (!(privconn->caps = testBuildCapabilities(conn)))
|
||||||
@ -1273,14 +1264,14 @@ testOpenFromFile(virConnectPtr conn, const char *file)
|
|||||||
|
|
||||||
xmlXPathFreeContext(ctxt);
|
xmlXPathFreeContext(ctxt);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
return VIR_DRV_OPEN_SUCCESS;
|
return VIR_DRV_OPEN_SUCCESS;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
xmlXPathFreeContext(ctxt);
|
xmlXPathFreeContext(ctxt);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
testDriverFree(privconn);
|
virObjectUnref(privconn);
|
||||||
conn->privateData = NULL;
|
conn->privateData = NULL;
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
}
|
}
|
||||||
@ -1298,8 +1289,8 @@ testOpenDefault(virConnectPtr conn)
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
virMutexLock(&defaultLock);
|
virMutexLock(&defaultLock);
|
||||||
if (defaultConnections++) {
|
if (defaultPrivconn) {
|
||||||
conn->privateData = defaultPrivconn;
|
conn->privateData = virObjectRef(defaultPrivconn);
|
||||||
virMutexUnlock(&defaultLock);
|
virMutexUnlock(&defaultLock);
|
||||||
return VIR_DRV_OPEN_SUCCESS;
|
return VIR_DRV_OPEN_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -1348,9 +1339,8 @@ testOpenDefault(virConnectPtr conn)
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
testDriverFree(privconn);
|
virObjectUnref(privconn);
|
||||||
conn->privateData = NULL;
|
conn->privateData = NULL;
|
||||||
defaultConnections--;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1363,9 +1353,9 @@ testConnectAuthenticate(virConnectPtr conn,
|
|||||||
ssize_t i;
|
ssize_t i;
|
||||||
char *username = NULL, *password = NULL;
|
char *username = NULL, *password = NULL;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
if (privconn->numAuths == 0) {
|
if (privconn->numAuths == 0) {
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1400,7 +1390,7 @@ testConnectAuthenticate(virConnectPtr conn,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
VIR_FREE(username);
|
VIR_FREE(username);
|
||||||
VIR_FREE(password);
|
VIR_FREE(password);
|
||||||
return ret;
|
return ret;
|
||||||
@ -1410,24 +1400,11 @@ testConnectAuthenticate(virConnectPtr conn,
|
|||||||
static void
|
static void
|
||||||
testDriverCloseInternal(testDriverPtr driver)
|
testDriverCloseInternal(testDriverPtr driver)
|
||||||
{
|
{
|
||||||
bool dflt = false;
|
virMutexLock(&defaultLock);
|
||||||
|
bool disposed = !virObjectUnref(driver);
|
||||||
if (driver == defaultPrivconn) {
|
if (disposed && driver == defaultPrivconn)
|
||||||
dflt = true;
|
|
||||||
virMutexLock(&defaultLock);
|
|
||||||
if (--defaultConnections) {
|
|
||||||
virMutexUnlock(&defaultLock);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
testDriverLock(driver);
|
|
||||||
testDriverFree(driver);
|
|
||||||
|
|
||||||
if (dflt) {
|
|
||||||
defaultPrivconn = NULL;
|
defaultPrivconn = NULL;
|
||||||
virMutexUnlock(&defaultLock);
|
virMutexUnlock(&defaultLock);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1546,9 +1523,9 @@ static int testNodeGetInfo(virConnectPtr conn,
|
|||||||
virNodeInfoPtr info)
|
virNodeInfoPtr info)
|
||||||
{
|
{
|
||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
memcpy(info, &privconn->nodeInfo, sizeof(virNodeInfo));
|
memcpy(info, &privconn->nodeInfo, sizeof(virNodeInfo));
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1556,9 +1533,9 @@ static char *testConnectGetCapabilities(virConnectPtr conn)
|
|||||||
{
|
{
|
||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
char *xml;
|
char *xml;
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
xml = virCapabilitiesFormatXML(privconn->caps);
|
xml = virCapabilitiesFormatXML(privconn->caps);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1593,9 +1570,9 @@ static int testConnectNumOfDomains(virConnectPtr conn)
|
|||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
count = virDomainObjListNumOfDomains(privconn->domains, true, NULL, NULL);
|
count = virDomainObjListNumOfDomains(privconn->domains, true, NULL, NULL);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@ -1648,7 +1625,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
if (flags & VIR_DOMAIN_START_VALIDATE)
|
if (flags & VIR_DOMAIN_START_VALIDATE)
|
||||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
|
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt,
|
if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt,
|
||||||
NULL, parse_flags)) == NULL)
|
NULL, parse_flags)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1680,7 +1657,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
virDomainObjEndAPI(&dom);
|
virDomainObjEndAPI(&dom);
|
||||||
virObjectEventStateQueue(privconn->eventState, event);
|
virObjectEventStateQueue(privconn->eventState, event);
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2842,7 +2819,7 @@ static int testNodeGetCellsFreeMemory(virConnectPtr conn,
|
|||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
if (startCell >= privconn->numCells) {
|
if (startCell >= privconn->numCells) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
"%s", _("Range exceeds available cells"));
|
"%s", _("Range exceeds available cells"));
|
||||||
@ -2857,7 +2834,7 @@ static int testNodeGetCellsFreeMemory(virConnectPtr conn,
|
|||||||
ret = i;
|
ret = i;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2915,12 +2892,12 @@ testNodeGetFreeMemory(virConnectPtr conn)
|
|||||||
unsigned int freeMem = 0;
|
unsigned int freeMem = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
|
|
||||||
for (i = 0; i < privconn->numCells; i++)
|
for (i = 0; i < privconn->numCells; i++)
|
||||||
freeMem += privconn->cells[i].freeMem;
|
freeMem += privconn->cells[i].freeMem;
|
||||||
|
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
return freeMem;
|
return freeMem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2957,7 +2934,7 @@ static int testDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
|
|
||||||
if (!(privdom = testDomObjFromDomain(domain)))
|
if (!(privdom = testDomObjFromDomain(domain)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2981,7 +2958,7 @@ static int testDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
|
|||||||
cleanup:
|
cleanup:
|
||||||
virDomainObjEndAPI(&privdom);
|
virDomainObjEndAPI(&privdom);
|
||||||
virObjectEventStateQueue(privconn->eventState, event);
|
virObjectEventStateQueue(privconn->eventState, event);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3746,9 +3723,9 @@ testInterfaceObjFindByName(testDriverPtr privconn,
|
|||||||
{
|
{
|
||||||
virInterfaceObjPtr obj;
|
virInterfaceObjPtr obj;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
obj = virInterfaceObjListFindByName(privconn->ifaces, name);
|
obj = virInterfaceObjListFindByName(privconn->ifaces, name);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
if (!obj)
|
if (!obj)
|
||||||
virReportError(VIR_ERR_NO_INTERFACE,
|
virReportError(VIR_ERR_NO_INTERFACE,
|
||||||
@ -3765,9 +3742,9 @@ testConnectNumOfInterfaces(virConnectPtr conn)
|
|||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
int ninterfaces;
|
int ninterfaces;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
ninterfaces = virInterfaceObjListNumOfInterfaces(privconn->ifaces, true);
|
ninterfaces = virInterfaceObjListNumOfInterfaces(privconn->ifaces, true);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
return ninterfaces;
|
return ninterfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3780,10 +3757,10 @@ testConnectListInterfaces(virConnectPtr conn,
|
|||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
int nnames;
|
int nnames;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
nnames = virInterfaceObjListGetNames(privconn->ifaces, true,
|
nnames = virInterfaceObjListGetNames(privconn->ifaces, true,
|
||||||
names, maxnames);
|
names, maxnames);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
return nnames;
|
return nnames;
|
||||||
}
|
}
|
||||||
@ -3795,9 +3772,9 @@ testConnectNumOfDefinedInterfaces(virConnectPtr conn)
|
|||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
int ninterfaces;
|
int ninterfaces;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
ninterfaces = virInterfaceObjListNumOfInterfaces(privconn->ifaces, false);
|
ninterfaces = virInterfaceObjListNumOfInterfaces(privconn->ifaces, false);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
return ninterfaces;
|
return ninterfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3810,10 +3787,10 @@ testConnectListDefinedInterfaces(virConnectPtr conn,
|
|||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
int nnames;
|
int nnames;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
nnames = virInterfaceObjListGetNames(privconn->ifaces, false,
|
nnames = virInterfaceObjListGetNames(privconn->ifaces, false,
|
||||||
names, maxnames);
|
names, maxnames);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
return nnames;
|
return nnames;
|
||||||
}
|
}
|
||||||
@ -3862,10 +3839,10 @@ testInterfaceLookupByMACString(virConnectPtr conn,
|
|||||||
char *ifacenames[] = { NULL, NULL };
|
char *ifacenames[] = { NULL, NULL };
|
||||||
virInterfacePtr ret = NULL;
|
virInterfacePtr ret = NULL;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
ifacect = virInterfaceObjListFindByMACString(privconn->ifaces, mac,
|
ifacect = virInterfaceObjListFindByMACString(privconn->ifaces, mac,
|
||||||
ifacenames, 2);
|
ifacenames, 2);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
if (ifacect == 0) {
|
if (ifacect == 0) {
|
||||||
virReportError(VIR_ERR_NO_INTERFACE,
|
virReportError(VIR_ERR_NO_INTERFACE,
|
||||||
@ -3913,7 +3890,7 @@ testInterfaceChangeBegin(virConnectPtr conn,
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
if (privconn->transaction_running) {
|
if (privconn->transaction_running) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("there is another transaction running."));
|
_("there is another transaction running."));
|
||||||
@ -3927,7 +3904,7 @@ testInterfaceChangeBegin(virConnectPtr conn,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3941,7 +3918,7 @@ testInterfaceChangeCommit(virConnectPtr conn,
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
|
|
||||||
if (!privconn->transaction_running) {
|
if (!privconn->transaction_running) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
@ -3956,7 +3933,7 @@ testInterfaceChangeCommit(virConnectPtr conn,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3971,7 +3948,7 @@ testInterfaceChangeRollback(virConnectPtr conn,
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
|
|
||||||
if (!privconn->transaction_running) {
|
if (!privconn->transaction_running) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
@ -3989,7 +3966,7 @@ testInterfaceChangeRollback(virConnectPtr conn,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4029,7 +4006,7 @@ testInterfaceDefineXML(virConnectPtr conn,
|
|||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
if ((def = virInterfaceDefParseString(xmlStr)) == NULL)
|
if ((def = virInterfaceDefParseString(xmlStr)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -4043,7 +4020,7 @@ testInterfaceDefineXML(virConnectPtr conn,
|
|||||||
cleanup:
|
cleanup:
|
||||||
virInterfaceDefFree(def);
|
virInterfaceDefFree(def);
|
||||||
virInterfaceObjEndAPI(&obj);
|
virInterfaceObjEndAPI(&obj);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4147,9 +4124,9 @@ testStoragePoolObjFindByName(testDriverPtr privconn,
|
|||||||
{
|
{
|
||||||
virStoragePoolObjPtr obj;
|
virStoragePoolObjPtr obj;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
obj = virStoragePoolObjFindByName(privconn->pools, name);
|
obj = virStoragePoolObjFindByName(privconn->pools, name);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
if (!obj)
|
if (!obj)
|
||||||
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
||||||
@ -4207,9 +4184,9 @@ testStoragePoolObjFindByUUID(testDriverPtr privconn,
|
|||||||
virStoragePoolObjPtr obj;
|
virStoragePoolObjPtr obj;
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
obj = virStoragePoolObjFindByUUID(privconn->pools, uuid);
|
obj = virStoragePoolObjFindByUUID(privconn->pools, uuid);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
virUUIDFormat(uuid, uuidstr);
|
virUUIDFormat(uuid, uuidstr);
|
||||||
@ -4275,10 +4252,10 @@ testConnectNumOfStoragePools(virConnectPtr conn)
|
|||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
int numActive = 0;
|
int numActive = 0;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
numActive = virStoragePoolObjNumOfStoragePools(privconn->pools, conn,
|
numActive = virStoragePoolObjNumOfStoragePools(privconn->pools, conn,
|
||||||
true, NULL);
|
true, NULL);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
return numActive;
|
return numActive;
|
||||||
}
|
}
|
||||||
@ -4292,10 +4269,10 @@ testConnectListStoragePools(virConnectPtr conn,
|
|||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
n = virStoragePoolObjGetNames(privconn->pools, conn, true, NULL,
|
n = virStoragePoolObjGetNames(privconn->pools, conn, true, NULL,
|
||||||
names, maxnames);
|
names, maxnames);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -4307,10 +4284,10 @@ testConnectNumOfDefinedStoragePools(virConnectPtr conn)
|
|||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
int numInactive = 0;
|
int numInactive = 0;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
numInactive = virStoragePoolObjNumOfStoragePools(privconn->pools, conn,
|
numInactive = virStoragePoolObjNumOfStoragePools(privconn->pools, conn,
|
||||||
false, NULL);
|
false, NULL);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
return numInactive;
|
return numInactive;
|
||||||
}
|
}
|
||||||
@ -4324,10 +4301,10 @@ testConnectListDefinedStoragePools(virConnectPtr conn,
|
|||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
n = virStoragePoolObjGetNames(privconn->pools, conn, false, NULL,
|
n = virStoragePoolObjGetNames(privconn->pools, conn, false, NULL,
|
||||||
names, maxnames);
|
names, maxnames);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -4343,10 +4320,10 @@ testConnectListAllStoragePools(virConnectPtr conn,
|
|||||||
|
|
||||||
virCheckFlags(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ALL, -1);
|
virCheckFlags(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ALL, -1);
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
ret = virStoragePoolObjListExport(conn, privconn->pools, pools,
|
ret = virStoragePoolObjListExport(conn, privconn->pools, pools,
|
||||||
NULL, flags);
|
NULL, flags);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -4508,7 +4485,7 @@ testStoragePoolCreateXML(virConnectPtr conn,
|
|||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
if (!(newDef = virStoragePoolDefParseString(xml)))
|
if (!(newDef = virStoragePoolDefParseString(xml)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -4556,7 +4533,7 @@ testStoragePoolCreateXML(virConnectPtr conn,
|
|||||||
virStoragePoolDefFree(newDef);
|
virStoragePoolDefFree(newDef);
|
||||||
virObjectEventStateQueue(privconn->eventState, event);
|
virObjectEventStateQueue(privconn->eventState, event);
|
||||||
virStoragePoolObjEndAPI(&obj);
|
virStoragePoolObjEndAPI(&obj);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4575,7 +4552,7 @@ testStoragePoolDefineXML(virConnectPtr conn,
|
|||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
if (!(newDef = virStoragePoolDefParseString(xml)))
|
if (!(newDef = virStoragePoolDefParseString(xml)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -4605,7 +4582,7 @@ testStoragePoolDefineXML(virConnectPtr conn,
|
|||||||
virStoragePoolDefFree(newDef);
|
virStoragePoolDefFree(newDef);
|
||||||
virObjectEventStateQueue(privconn->eventState, event);
|
virObjectEventStateQueue(privconn->eventState, event);
|
||||||
virStoragePoolObjEndAPI(&obj);
|
virStoragePoolObjEndAPI(&obj);
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5006,7 +4983,7 @@ testStorageVolLookupByKey(virConnectPtr conn,
|
|||||||
.key = key, .voldef = NULL };
|
.key = key, .voldef = NULL };
|
||||||
virStorageVolPtr vol = NULL;
|
virStorageVolPtr vol = NULL;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
if ((obj = virStoragePoolObjListSearch(privconn->pools,
|
if ((obj = virStoragePoolObjListSearch(privconn->pools,
|
||||||
testStorageVolLookupByKeyCallback,
|
testStorageVolLookupByKeyCallback,
|
||||||
&data)) && data.voldef) {
|
&data)) && data.voldef) {
|
||||||
@ -5016,7 +4993,7 @@ testStorageVolLookupByKey(virConnectPtr conn,
|
|||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
virStoragePoolObjEndAPI(&obj);
|
virStoragePoolObjEndAPI(&obj);
|
||||||
}
|
}
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
if (!vol)
|
if (!vol)
|
||||||
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
||||||
@ -5050,7 +5027,7 @@ testStorageVolLookupByPath(virConnectPtr conn,
|
|||||||
.path = path, .voldef = NULL };
|
.path = path, .voldef = NULL };
|
||||||
virStorageVolPtr vol = NULL;
|
virStorageVolPtr vol = NULL;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
virObjectLock(privconn);
|
||||||
if ((obj = virStoragePoolObjListSearch(privconn->pools,
|
if ((obj = virStoragePoolObjListSearch(privconn->pools,
|
||||||
testStorageVolLookupByPathCallback,
|
testStorageVolLookupByPathCallback,
|
||||||
&data)) && data.voldef) {
|
&data)) && data.voldef) {
|
||||||
@ -5060,7 +5037,7 @@ testStorageVolLookupByPath(virConnectPtr conn,
|
|||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
virStoragePoolObjEndAPI(&obj);
|
virStoragePoolObjEndAPI(&obj);
|
||||||
}
|
}
|
||||||
testDriverUnlock(privconn);
|
virObjectUnlock(privconn);
|
||||||
|
|
||||||
if (!vol)
|
if (!vol)
|
||||||
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
||||||
@ -6819,7 +6796,6 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static virHypervisorDriver testHypervisorDriver = {
|
static virHypervisorDriver testHypervisorDriver = {
|
||||||
.name = "Test",
|
.name = "Test",
|
||||||
.connectOpen = testConnectOpen, /* 0.1.1 */
|
.connectOpen = testConnectOpen, /* 0.1.1 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user