storage: Privatize virStoragePoolObjListPtr

Move the structure into virstorageobj.c.

Use the virStoragePoolObjListNew allocator to fill in the @pools for
the storage driver and test driver.
This commit is contained in:
John Ferlan 2017-10-07 07:24:24 -04:00
parent d4f80d439e
commit 90e65353a2
5 changed files with 82 additions and 62 deletions

View File

@ -62,6 +62,11 @@ struct _virStoragePoolObj {
virStorageVolDefList volumes; virStorageVolDefList volumes;
}; };
struct _virStoragePoolObjList {
size_t count;
virStoragePoolObjPtr *objs;
};
static int static int
virStoragePoolObjOnceInit(void) virStoragePoolObjOnceInit(void)
@ -241,7 +246,19 @@ virStoragePoolObjListFree(virStoragePoolObjListPtr pools)
for (i = 0; i < pools->count; i++) for (i = 0; i < pools->count; i++)
virObjectUnref(pools->objs[i]); virObjectUnref(pools->objs[i]);
VIR_FREE(pools->objs); VIR_FREE(pools->objs);
pools->count = 0; VIR_FREE(pools);
}
virStoragePoolObjListPtr
virStoragePoolObjListNew(void)
{
virStoragePoolObjListPtr pools;
if (VIR_ALLOC(pools) < 0)
return NULL;
return pools;
} }

View File

@ -29,10 +29,6 @@ typedef virStoragePoolObj *virStoragePoolObjPtr;
typedef struct _virStoragePoolObjList virStoragePoolObjList; typedef struct _virStoragePoolObjList virStoragePoolObjList;
typedef virStoragePoolObjList *virStoragePoolObjListPtr; typedef virStoragePoolObjList *virStoragePoolObjListPtr;
struct _virStoragePoolObjList {
size_t count;
virStoragePoolObjPtr *objs;
};
typedef struct _virStorageDriverState virStorageDriverState; typedef struct _virStorageDriverState virStorageDriverState;
typedef virStorageDriverState *virStorageDriverStatePtr; typedef virStorageDriverState *virStorageDriverStatePtr;
@ -40,7 +36,7 @@ typedef virStorageDriverState *virStorageDriverStatePtr;
struct _virStorageDriverState { struct _virStorageDriverState {
virMutex lock; virMutex lock;
virStoragePoolObjList pools; virStoragePoolObjListPtr pools;
char *configDir; char *configDir;
char *autostartDir; char *autostartDir;
@ -244,6 +240,9 @@ virStoragePoolObjListSearch(virStoragePoolObjListPtr pools,
virStoragePoolObjListSearcher searcher, virStoragePoolObjListSearcher searcher,
const void *opaque); const void *opaque);
virStoragePoolObjListPtr
virStoragePoolObjListNew(void);
void void
virStoragePoolObjRemove(virStoragePoolObjListPtr pools, virStoragePoolObjRemove(virStoragePoolObjListPtr pools,
virStoragePoolObjPtr obj); virStoragePoolObjPtr obj);

View File

@ -1096,6 +1096,7 @@ virStoragePoolObjIsDuplicate;
virStoragePoolObjListExport; virStoragePoolObjListExport;
virStoragePoolObjListForEach; virStoragePoolObjListForEach;
virStoragePoolObjListFree; virStoragePoolObjListFree;
virStoragePoolObjListNew;
virStoragePoolObjListSearch; virStoragePoolObjListSearch;
virStoragePoolObjLoadAllConfigs; virStoragePoolObjLoadAllConfigs;
virStoragePoolObjLoadAllState; virStoragePoolObjLoadAllState;

View File

@ -93,7 +93,7 @@ virStoragePoolUpdateInactive(virStoragePoolObjPtr *objptr)
virStoragePoolObjPtr obj = *objptr; virStoragePoolObjPtr obj = *objptr;
if (!virStoragePoolObjGetConfigFile(obj)) { if (!virStoragePoolObjGetConfigFile(obj)) {
virStoragePoolObjRemove(&driver->pools, obj); virStoragePoolObjRemove(driver->pools, obj);
*objptr = NULL; *objptr = NULL;
} else if (virStoragePoolObjGetNewDef(obj)) { } else if (virStoragePoolObjGetNewDef(obj)) {
virStoragePoolObjDefUseNewDef(obj); virStoragePoolObjDefUseNewDef(obj);
@ -162,7 +162,7 @@ storagePoolUpdateStateCallback(virStoragePoolObjPtr obj,
static void static void
storagePoolUpdateAllState(void) storagePoolUpdateAllState(void)
{ {
virStoragePoolObjListForEach(&driver->pools, virStoragePoolObjListForEach(driver->pools,
storagePoolUpdateStateCallback, storagePoolUpdateStateCallback,
NULL); NULL);
} }
@ -227,7 +227,7 @@ storageDriverAutostart(void)
conn = virConnectOpen("qemu:///session"); conn = virConnectOpen("qemu:///session");
/* Ignoring NULL conn - let backends decide */ /* Ignoring NULL conn - let backends decide */
virStoragePoolObjListForEach(&driver->pools, virStoragePoolObjListForEach(driver->pools,
storageDriverAutostartCallback, storageDriverAutostartCallback,
conn); conn);
@ -257,6 +257,9 @@ storageStateInitialize(bool privileged,
} }
storageDriverLock(); storageDriverLock();
if (!(driver->pools = virStoragePoolObjListNew()))
goto error;
if (privileged) { if (privileged) {
if (VIR_STRDUP(driver->configDir, if (VIR_STRDUP(driver->configDir,
SYSCONFDIR "/libvirt/storage") < 0 || SYSCONFDIR "/libvirt/storage") < 0 ||
@ -288,11 +291,11 @@ storageStateInitialize(bool privileged,
goto error; goto error;
} }
if (virStoragePoolObjLoadAllState(&driver->pools, if (virStoragePoolObjLoadAllState(driver->pools,
driver->stateDir) < 0) driver->stateDir) < 0)
goto error; goto error;
if (virStoragePoolObjLoadAllConfigs(&driver->pools, if (virStoragePoolObjLoadAllConfigs(driver->pools,
driver->configDir, driver->configDir,
driver->autostartDir) < 0) driver->autostartDir) < 0)
goto error; goto error;
@ -344,9 +347,9 @@ storageStateReload(void)
return -1; return -1;
storageDriverLock(); storageDriverLock();
virStoragePoolObjLoadAllState(&driver->pools, virStoragePoolObjLoadAllState(driver->pools,
driver->stateDir); driver->stateDir);
virStoragePoolObjLoadAllConfigs(&driver->pools, virStoragePoolObjLoadAllConfigs(driver->pools,
driver->configDir, driver->configDir,
driver->autostartDir); driver->autostartDir);
storageDriverAutostart(); storageDriverAutostart();
@ -372,7 +375,7 @@ storageStateCleanup(void)
virObjectUnref(driver->storageEventState); virObjectUnref(driver->storageEventState);
/* free inactive pools */ /* free inactive pools */
virStoragePoolObjListFree(&driver->pools); virStoragePoolObjListFree(driver->pools);
VIR_FREE(driver->configDir); VIR_FREE(driver->configDir);
VIR_FREE(driver->autostartDir); VIR_FREE(driver->autostartDir);
@ -392,7 +395,7 @@ storagePoolObjFindByUUID(const unsigned char *uuid,
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!(obj = virStoragePoolObjFindByUUID(&driver->pools, uuid))) { if (!(obj = virStoragePoolObjFindByUUID(driver->pools, uuid))) {
virUUIDFormat(uuid, uuidstr); virUUIDFormat(uuid, uuidstr);
if (name) if (name)
virReportError(VIR_ERR_NO_STORAGE_POOL, virReportError(VIR_ERR_NO_STORAGE_POOL,
@ -427,7 +430,7 @@ storagePoolObjFindByName(const char *name)
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
storageDriverLock(); storageDriverLock();
if (!(obj = virStoragePoolObjFindByName(&driver->pools, name))) if (!(obj = virStoragePoolObjFindByName(driver->pools, name)))
virReportError(VIR_ERR_NO_STORAGE_POOL, virReportError(VIR_ERR_NO_STORAGE_POOL,
_("no storage pool with matching name '%s'"), name); _("no storage pool with matching name '%s'"), name);
storageDriverUnlock(); storageDriverUnlock();
@ -513,7 +516,7 @@ storageConnectNumOfStoragePools(virConnectPtr conn)
return -1; return -1;
storageDriverLock(); storageDriverLock();
nactive = virStoragePoolObjNumOfStoragePools(&driver->pools, conn, true, nactive = virStoragePoolObjNumOfStoragePools(driver->pools, conn, true,
virConnectNumOfStoragePoolsCheckACL); virConnectNumOfStoragePoolsCheckACL);
storageDriverUnlock(); storageDriverUnlock();
@ -532,7 +535,7 @@ storageConnectListStoragePools(virConnectPtr conn,
return -1; return -1;
storageDriverLock(); storageDriverLock();
got = virStoragePoolObjGetNames(&driver->pools, conn, true, got = virStoragePoolObjGetNames(driver->pools, conn, true,
virConnectListStoragePoolsCheckACL, virConnectListStoragePoolsCheckACL,
names, maxnames); names, maxnames);
storageDriverUnlock(); storageDriverUnlock();
@ -548,7 +551,7 @@ storageConnectNumOfDefinedStoragePools(virConnectPtr conn)
return -1; return -1;
storageDriverLock(); storageDriverLock();
nactive = virStoragePoolObjNumOfStoragePools(&driver->pools, conn, false, nactive = virStoragePoolObjNumOfStoragePools(driver->pools, conn, false,
virConnectNumOfDefinedStoragePoolsCheckACL); virConnectNumOfDefinedStoragePoolsCheckACL);
storageDriverUnlock(); storageDriverUnlock();
@ -567,7 +570,7 @@ storageConnectListDefinedStoragePools(virConnectPtr conn,
return -1; return -1;
storageDriverLock(); storageDriverLock();
got = virStoragePoolObjGetNames(&driver->pools, conn, false, got = virStoragePoolObjGetNames(driver->pools, conn, false,
virConnectListDefinedStoragePoolsCheckACL, virConnectListDefinedStoragePoolsCheckACL,
names, maxnames); names, maxnames);
storageDriverUnlock(); storageDriverUnlock();
@ -686,16 +689,16 @@ storagePoolCreateXML(virConnectPtr conn,
if (virStoragePoolCreateXMLEnsureACL(conn, newDef) < 0) if (virStoragePoolCreateXMLEnsureACL(conn, newDef) < 0)
goto cleanup; goto cleanup;
if (virStoragePoolObjIsDuplicate(&driver->pools, newDef, 1) < 0) if (virStoragePoolObjIsDuplicate(driver->pools, newDef, 1) < 0)
goto cleanup; goto cleanup;
if (virStoragePoolObjSourceFindDuplicate(conn, &driver->pools, newDef) < 0) if (virStoragePoolObjSourceFindDuplicate(conn, driver->pools, newDef) < 0)
goto cleanup; goto cleanup;
if ((backend = virStorageBackendForType(newDef->type)) == NULL) if ((backend = virStorageBackendForType(newDef->type)) == NULL)
goto cleanup; goto cleanup;
if (!(obj = virStoragePoolObjAssignDef(&driver->pools, newDef))) if (!(obj = virStoragePoolObjAssignDef(driver->pools, newDef)))
goto cleanup; goto cleanup;
newDef = NULL; newDef = NULL;
def = virStoragePoolObjGetDef(obj); def = virStoragePoolObjGetDef(obj);
@ -709,7 +712,7 @@ storagePoolCreateXML(virConnectPtr conn,
if (build_flags || if (build_flags ||
(flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD)) { (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD)) {
if (backend->buildPool(conn, obj, build_flags) < 0) { if (backend->buildPool(conn, obj, build_flags) < 0) {
virStoragePoolObjRemove(&driver->pools, obj); virStoragePoolObjRemove(driver->pools, obj);
obj = NULL; obj = NULL;
goto cleanup; goto cleanup;
} }
@ -718,7 +721,7 @@ storagePoolCreateXML(virConnectPtr conn,
if (backend->startPool && if (backend->startPool &&
backend->startPool(conn, obj) < 0) { backend->startPool(conn, obj) < 0) {
virStoragePoolObjRemove(&driver->pools, obj); virStoragePoolObjRemove(driver->pools, obj);
obj = NULL; obj = NULL;
goto cleanup; goto cleanup;
} }
@ -732,7 +735,7 @@ storagePoolCreateXML(virConnectPtr conn,
unlink(stateFile); unlink(stateFile);
if (backend->stopPool) if (backend->stopPool)
backend->stopPool(conn, obj); backend->stopPool(conn, obj);
virStoragePoolObjRemove(&driver->pools, obj); virStoragePoolObjRemove(driver->pools, obj);
obj = NULL; obj = NULL;
goto cleanup; goto cleanup;
} }
@ -780,22 +783,22 @@ storagePoolDefineXML(virConnectPtr conn,
if (virStoragePoolDefineXMLEnsureACL(conn, newDef) < 0) if (virStoragePoolDefineXMLEnsureACL(conn, newDef) < 0)
goto cleanup; goto cleanup;
if (virStoragePoolObjIsDuplicate(&driver->pools, newDef, 0) < 0) if (virStoragePoolObjIsDuplicate(driver->pools, newDef, 0) < 0)
goto cleanup; goto cleanup;
if (virStoragePoolObjSourceFindDuplicate(conn, &driver->pools, newDef) < 0) if (virStoragePoolObjSourceFindDuplicate(conn, driver->pools, newDef) < 0)
goto cleanup; goto cleanup;
if (virStorageBackendForType(newDef->type) == NULL) if (virStorageBackendForType(newDef->type) == NULL)
goto cleanup; goto cleanup;
if (!(obj = virStoragePoolObjAssignDef(&driver->pools, newDef))) if (!(obj = virStoragePoolObjAssignDef(driver->pools, newDef)))
goto cleanup; goto cleanup;
newDef = NULL; newDef = NULL;
def = virStoragePoolObjGetDef(obj); def = virStoragePoolObjGetDef(obj);
if (virStoragePoolObjSaveDef(driver, obj, def) < 0) { if (virStoragePoolObjSaveDef(driver, obj, def) < 0) {
virStoragePoolObjRemove(&driver->pools, obj); virStoragePoolObjRemove(driver->pools, obj);
obj = NULL; obj = NULL;
goto cleanup; goto cleanup;
} }
@ -864,7 +867,7 @@ storagePoolUndefine(virStoragePoolPtr pool)
0); 0);
VIR_INFO("Undefining storage pool '%s'", def->name); VIR_INFO("Undefining storage pool '%s'", def->name);
virStoragePoolObjRemove(&driver->pools, obj); virStoragePoolObjRemove(driver->pools, obj);
obj = NULL; obj = NULL;
ret = 0; ret = 0;
@ -1521,7 +1524,7 @@ storageVolLookupByKey(virConnectPtr conn,
virStorageVolPtr vol = NULL; virStorageVolPtr vol = NULL;
storageDriverLock(); storageDriverLock();
if ((obj = virStoragePoolObjListSearch(&driver->pools, if ((obj = virStoragePoolObjListSearch(driver->pools,
storageVolLookupByKeyCallback, storageVolLookupByKeyCallback,
&data)) && data.voldef) { &data)) && data.voldef) {
def = virStoragePoolObjGetDef(obj); def = virStoragePoolObjGetDef(obj);
@ -1606,7 +1609,7 @@ storageVolLookupByPath(virConnectPtr conn,
return NULL; return NULL;
storageDriverLock(); storageDriverLock();
if ((obj = virStoragePoolObjListSearch(&driver->pools, if ((obj = virStoragePoolObjListSearch(driver->pools,
storageVolLookupByPathCallback, storageVolLookupByPathCallback,
&data)) && data.voldef) { &data)) && data.voldef) {
def = virStoragePoolObjGetDef(obj); def = virStoragePoolObjGetDef(obj);
@ -1665,7 +1668,7 @@ storagePoolLookupByTargetPath(virConnectPtr conn,
return NULL; return NULL;
storageDriverLock(); storageDriverLock();
if ((obj = virStoragePoolObjListSearch(&driver->pools, if ((obj = virStoragePoolObjListSearch(driver->pools,
storagePoolLookupByTargetPathCallback, storagePoolLookupByTargetPathCallback,
cleanpath))) { cleanpath))) {
def = virStoragePoolObjGetDef(obj); def = virStoragePoolObjGetDef(obj);
@ -1971,10 +1974,10 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
NULL); NULL);
storageDriverLock(); storageDriverLock();
obj = virStoragePoolObjFindByUUID(&driver->pools, pool->uuid); obj = virStoragePoolObjFindByUUID(driver->pools, pool->uuid);
if (obj && STRNEQ(pool->name, volsrc->pool)) { if (obj && STRNEQ(pool->name, volsrc->pool)) {
virObjectUnlock(obj); virObjectUnlock(obj);
objsrc = virStoragePoolObjFindByName(&driver->pools, volsrc->pool); objsrc = virStoragePoolObjFindByName(driver->pools, volsrc->pool);
virObjectLock(obj); virObjectLock(obj);
} }
storageDriverUnlock(); storageDriverUnlock();
@ -2271,7 +2274,7 @@ virStorageVolPoolRefreshThread(void *opaque)
if (virStorageBackendPloopRestoreDesc(cbdata->vol_path) < 0) if (virStorageBackendPloopRestoreDesc(cbdata->vol_path) < 0)
goto cleanup; goto cleanup;
} }
if (!(obj = virStoragePoolObjFindByName(&driver->pools, if (!(obj = virStoragePoolObjFindByName(driver->pools,
cbdata->pool_name))) cbdata->pool_name)))
goto cleanup; goto cleanup;
def = virStoragePoolObjGetDef(obj); def = virStoragePoolObjGetDef(obj);
@ -2687,7 +2690,7 @@ storageConnectListAllStoragePools(virConnectPtr conn,
goto cleanup; goto cleanup;
storageDriverLock(); storageDriverLock();
ret = virStoragePoolObjListExport(conn, &driver->pools, pools, ret = virStoragePoolObjListExport(conn, driver->pools, pools,
virConnectListAllStoragePoolsCheckACL, virConnectListAllStoragePoolsCheckACL,
flags); flags);
storageDriverUnlock(); storageDriverUnlock();
@ -3092,7 +3095,7 @@ virStoragePoolObjFindPoolByUUID(const unsigned char *uuid)
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
storageDriverLock(); storageDriverLock();
obj = virStoragePoolObjFindByUUID(&driver->pools, uuid); obj = virStoragePoolObjFindByUUID(driver->pools, uuid);
storageDriverUnlock(); storageDriverUnlock();
return obj; return obj;
} }

View File

@ -100,7 +100,7 @@ struct _testDriver {
virInterfaceObjListPtr ifaces; virInterfaceObjListPtr ifaces;
bool transaction_running; bool transaction_running;
virInterfaceObjListPtr backupIfaces; virInterfaceObjListPtr backupIfaces;
virStoragePoolObjList pools; virStoragePoolObjListPtr pools;
virNodeDeviceObjListPtr devs; virNodeDeviceObjListPtr devs;
int numCells; int numCells;
testCell cells[MAX_CELLS]; testCell cells[MAX_CELLS];
@ -155,7 +155,7 @@ testDriverFree(testDriverPtr driver)
virNodeDeviceObjListFree(driver->devs); virNodeDeviceObjListFree(driver->devs);
virObjectUnref(driver->networks); virObjectUnref(driver->networks);
virObjectUnref(driver->ifaces); virObjectUnref(driver->ifaces);
virStoragePoolObjListFree(&driver->pools); virStoragePoolObjListFree(driver->pools);
virObjectUnref(driver->eventState); virObjectUnref(driver->eventState);
virMutexUnlock(&driver->lock); virMutexUnlock(&driver->lock);
virMutexDestroy(&driver->lock); virMutexDestroy(&driver->lock);
@ -419,7 +419,8 @@ testDriverNew(void)
!(ret->ifaces = virInterfaceObjListNew()) || !(ret->ifaces = virInterfaceObjListNew()) ||
!(ret->domains = virDomainObjListNew()) || !(ret->domains = virDomainObjListNew()) ||
!(ret->networks = virNetworkObjListNew()) || !(ret->networks = virNetworkObjListNew()) ||
!(ret->devs = virNodeDeviceObjListNew())) !(ret->devs = virNodeDeviceObjListNew()) ||
!(ret->pools = virStoragePoolObjListNew()))
goto error; goto error;
virAtomicIntSet(&ret->nextDomID, 1); virAtomicIntSet(&ret->nextDomID, 1);
@ -1112,8 +1113,7 @@ testParseStorage(testDriverPtr privconn,
if (!def) if (!def)
goto error; goto error;
if (!(obj = virStoragePoolObjAssignDef(&privconn->pools, if (!(obj = virStoragePoolObjAssignDef(privconn->pools, def))) {
def))) {
virStoragePoolDefFree(def); virStoragePoolDefFree(def);
goto error; goto error;
} }
@ -4076,7 +4076,7 @@ testStoragePoolObjFindByName(testDriverPtr privconn,
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
testDriverLock(privconn); testDriverLock(privconn);
obj = virStoragePoolObjFindByName(&privconn->pools, name); obj = virStoragePoolObjFindByName(privconn->pools, name);
testDriverUnlock(privconn); testDriverUnlock(privconn);
if (!obj) if (!obj)
@ -4136,7 +4136,7 @@ testStoragePoolObjFindByUUID(testDriverPtr privconn,
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
testDriverLock(privconn); testDriverLock(privconn);
obj = virStoragePoolObjFindByUUID(&privconn->pools, uuid); obj = virStoragePoolObjFindByUUID(privconn->pools, uuid);
testDriverUnlock(privconn); testDriverUnlock(privconn);
if (!obj) { if (!obj) {
@ -4204,7 +4204,7 @@ testConnectNumOfStoragePools(virConnectPtr conn)
int numActive = 0; int numActive = 0;
testDriverLock(privconn); testDriverLock(privconn);
numActive = virStoragePoolObjNumOfStoragePools(&privconn->pools, conn, numActive = virStoragePoolObjNumOfStoragePools(privconn->pools, conn,
true, NULL); true, NULL);
testDriverUnlock(privconn); testDriverUnlock(privconn);
@ -4221,7 +4221,7 @@ testConnectListStoragePools(virConnectPtr conn,
int n = 0; int n = 0;
testDriverLock(privconn); testDriverLock(privconn);
n = virStoragePoolObjGetNames(&privconn->pools, conn, true, NULL, n = virStoragePoolObjGetNames(privconn->pools, conn, true, NULL,
names, maxnames); names, maxnames);
testDriverUnlock(privconn); testDriverUnlock(privconn);
@ -4236,7 +4236,7 @@ testConnectNumOfDefinedStoragePools(virConnectPtr conn)
int numInactive = 0; int numInactive = 0;
testDriverLock(privconn); testDriverLock(privconn);
numInactive = virStoragePoolObjNumOfStoragePools(&privconn->pools, conn, numInactive = virStoragePoolObjNumOfStoragePools(privconn->pools, conn,
false, NULL); false, NULL);
testDriverUnlock(privconn); testDriverUnlock(privconn);
@ -4253,7 +4253,7 @@ testConnectListDefinedStoragePools(virConnectPtr conn,
int n = 0; int n = 0;
testDriverLock(privconn); testDriverLock(privconn);
n = virStoragePoolObjGetNames(&privconn->pools, conn, false, NULL, n = virStoragePoolObjGetNames(privconn->pools, conn, false, NULL,
names, maxnames); names, maxnames);
testDriverUnlock(privconn); testDriverUnlock(privconn);
@ -4272,7 +4272,7 @@ testConnectListAllStoragePools(virConnectPtr conn,
virCheckFlags(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ALL, -1); virCheckFlags(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ALL, -1);
testDriverLock(privconn); testDriverLock(privconn);
ret = virStoragePoolObjListExport(conn, &privconn->pools, pools, ret = virStoragePoolObjListExport(conn, privconn->pools, pools,
NULL, flags); NULL, flags);
testDriverUnlock(privconn); testDriverUnlock(privconn);
@ -4440,16 +4440,16 @@ testStoragePoolCreateXML(virConnectPtr conn,
if (!(newDef = virStoragePoolDefParseString(xml))) if (!(newDef = virStoragePoolDefParseString(xml)))
goto cleanup; goto cleanup;
obj = virStoragePoolObjFindByUUID(&privconn->pools, newDef->uuid); obj = virStoragePoolObjFindByUUID(privconn->pools, newDef->uuid);
if (!obj) if (!obj)
obj = virStoragePoolObjFindByName(&privconn->pools, newDef->name); obj = virStoragePoolObjFindByName(privconn->pools, newDef->name);
if (obj) { if (obj) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("storage pool already exists")); "%s", _("storage pool already exists"));
goto cleanup; goto cleanup;
} }
if (!(obj = virStoragePoolObjAssignDef(&privconn->pools, newDef))) if (!(obj = virStoragePoolObjAssignDef(privconn->pools, newDef)))
goto cleanup; goto cleanup;
newDef = NULL; newDef = NULL;
def = virStoragePoolObjGetDef(obj); def = virStoragePoolObjGetDef(obj);
@ -4462,14 +4462,14 @@ testStoragePoolCreateXML(virConnectPtr conn,
if (testCreateVport(privconn, if (testCreateVport(privconn,
def->source.adapter.data.fchost.wwnn, def->source.adapter.data.fchost.wwnn,
def->source.adapter.data.fchost.wwpn) < 0) { def->source.adapter.data.fchost.wwpn) < 0) {
virStoragePoolObjRemove(&privconn->pools, obj); virStoragePoolObjRemove(privconn->pools, obj);
obj = NULL; obj = NULL;
goto cleanup; goto cleanup;
} }
} }
if (testStoragePoolObjSetDefaults(obj) == -1) { if (testStoragePoolObjSetDefaults(obj) == -1) {
virStoragePoolObjRemove(&privconn->pools, obj); virStoragePoolObjRemove(privconn->pools, obj);
obj = NULL; obj = NULL;
goto cleanup; goto cleanup;
} }
@ -4518,7 +4518,7 @@ testStoragePoolDefineXML(virConnectPtr conn,
newDef->allocation = defaultPoolAlloc; newDef->allocation = defaultPoolAlloc;
newDef->available = defaultPoolCap - defaultPoolAlloc; newDef->available = defaultPoolCap - defaultPoolAlloc;
if (!(obj = virStoragePoolObjAssignDef(&privconn->pools, newDef))) if (!(obj = virStoragePoolObjAssignDef(privconn->pools, newDef)))
goto cleanup; goto cleanup;
newDef = NULL; newDef = NULL;
def = virStoragePoolObjGetDef(obj); def = virStoragePoolObjGetDef(obj);
@ -4528,7 +4528,7 @@ testStoragePoolDefineXML(virConnectPtr conn,
0); 0);
if (testStoragePoolObjSetDefaults(obj) == -1) { if (testStoragePoolObjSetDefaults(obj) == -1) {
virStoragePoolObjRemove(&privconn->pools, obj); virStoragePoolObjRemove(privconn->pools, obj);
obj = NULL; obj = NULL;
goto cleanup; goto cleanup;
} }
@ -4558,7 +4558,7 @@ testStoragePoolUndefine(virStoragePoolPtr pool)
VIR_STORAGE_POOL_EVENT_UNDEFINED, VIR_STORAGE_POOL_EVENT_UNDEFINED,
0); 0);
virStoragePoolObjRemove(&privconn->pools, obj); virStoragePoolObjRemove(privconn->pools, obj);
testObjectEventQueue(privconn, event); testObjectEventQueue(privconn, event);
return 0; return 0;
@ -4651,7 +4651,7 @@ testStoragePoolDestroy(virStoragePoolPtr pool)
0); 0);
if (!(virStoragePoolObjGetConfigFile(obj))) { if (!(virStoragePoolObjGetConfigFile(obj))) {
virStoragePoolObjRemove(&privconn->pools, obj); virStoragePoolObjRemove(privconn->pools, obj);
obj = NULL; obj = NULL;
} }
ret = 0; ret = 0;
@ -4940,7 +4940,7 @@ testStorageVolLookupByKey(virConnectPtr conn,
virStorageVolPtr vol = NULL; virStorageVolPtr vol = NULL;
testDriverLock(privconn); testDriverLock(privconn);
if ((obj = virStoragePoolObjListSearch(&privconn->pools, if ((obj = virStoragePoolObjListSearch(privconn->pools,
testStorageVolLookupByKeyCallback, testStorageVolLookupByKeyCallback,
&data)) && data.voldef) { &data)) && data.voldef) {
def = virStoragePoolObjGetDef(obj); def = virStoragePoolObjGetDef(obj);
@ -4984,7 +4984,7 @@ testStorageVolLookupByPath(virConnectPtr conn,
virStorageVolPtr vol = NULL; virStorageVolPtr vol = NULL;
testDriverLock(privconn); testDriverLock(privconn);
if ((obj = virStoragePoolObjListSearch(&privconn->pools, if ((obj = virStoragePoolObjListSearch(privconn->pools,
testStorageVolLookupByPathCallback, testStorageVolLookupByPathCallback,
&data)) && data.voldef) { &data)) && data.voldef) {
def = virStoragePoolObjGetDef(obj); def = virStoragePoolObjGetDef(obj);