提交 036d9af3 编写于 作者: J John Ferlan

test: Use consistent variable names for storage test driver APIs

A virStoragePoolObjPtr will be an 'obj'.

A virStoragePoolPtr will be a 'pool'.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 f51b78ed
...@@ -567,7 +567,7 @@ static const char *defaultPoolSourcesNetFSXML = ...@@ -567,7 +567,7 @@ static const char *defaultPoolSourcesNetFSXML =
static const unsigned long long defaultPoolCap = (100 * 1024 * 1024 * 1024ull); static const unsigned long long defaultPoolCap = (100 * 1024 * 1024 * 1024ull);
static const unsigned long long defaultPoolAlloc; static const unsigned long long defaultPoolAlloc;
static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool); static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr obj);
static int testNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info); static int testNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info);
static virDomainObjPtr static virDomainObjPtr
...@@ -1043,8 +1043,8 @@ testParseInterfaces(testDriverPtr privconn, ...@@ -1043,8 +1043,8 @@ testParseInterfaces(testDriverPtr privconn,
static int static int
testOpenVolumesForPool(const char *file, testOpenVolumesForPool(const char *file,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
virStoragePoolObjPtr pool, virStoragePoolObjPtr obj,
int poolidx) int objidx)
{ {
char *vol_xpath; char *vol_xpath;
size_t i; size_t i;
...@@ -1053,7 +1053,7 @@ testOpenVolumesForPool(const char *file, ...@@ -1053,7 +1053,7 @@ testOpenVolumesForPool(const char *file,
virStorageVolDefPtr def = NULL; virStorageVolDefPtr def = NULL;
/* Find storage volumes */ /* Find storage volumes */
if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", poolidx) < 0) if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", objidx) < 0)
goto error; goto error;
num = virXPathNodeSet(vol_xpath, ctxt, &nodes); num = virXPathNodeSet(vol_xpath, ctxt, &nodes);
...@@ -1067,25 +1067,24 @@ testOpenVolumesForPool(const char *file, ...@@ -1067,25 +1067,24 @@ testOpenVolumesForPool(const char *file,
if (!node) if (!node)
goto error; goto error;
def = virStorageVolDefParseNode(pool->def, ctxt->doc, node, 0); def = virStorageVolDefParseNode(obj->def, ctxt->doc, node, 0);
if (!def) if (!def)
goto error; goto error;
if (def->target.path == NULL) { if (def->target.path == NULL) {
if (virAsprintf(&def->target.path, "%s/%s", if (virAsprintf(&def->target.path, "%s/%s",
pool->def->target.path, obj->def->target.path,
def->name) == -1) def->name) == -1)
goto error; goto error;
} }
if (!def->key && VIR_STRDUP(def->key, def->target.path) < 0) if (!def->key && VIR_STRDUP(def->key, def->target.path) < 0)
goto error; goto error;
if (VIR_APPEND_ELEMENT_COPY(pool->volumes.objs, pool->volumes.count, def) < 0) if (VIR_APPEND_ELEMENT_COPY(obj->volumes.objs, obj->volumes.count, def) < 0)
goto error; goto error;
pool->def->allocation += def->target.allocation; obj->def->allocation += def->target.allocation;
pool->def->available = (pool->def->capacity - obj->def->available = (obj->def->capacity - obj->def->allocation);
pool->def->allocation);
def = NULL; def = NULL;
} }
...@@ -4039,14 +4038,14 @@ testInterfaceDestroy(virInterfacePtr iface, ...@@ -4039,14 +4038,14 @@ testInterfaceDestroy(virInterfacePtr iface,
*/ */
static int static int
testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool) testStoragePoolObjSetDefaults(virStoragePoolObjPtr obj)
{ {
pool->def->capacity = defaultPoolCap; obj->def->capacity = defaultPoolCap;
pool->def->allocation = defaultPoolAlloc; obj->def->allocation = defaultPoolAlloc;
pool->def->available = defaultPoolCap - defaultPoolAlloc; obj->def->available = defaultPoolCap - defaultPoolAlloc;
return VIR_STRDUP(pool->configFile, ""); return VIR_STRDUP(obj->configFile, "");
} }
...@@ -4054,18 +4053,18 @@ static virStoragePoolObjPtr ...@@ -4054,18 +4053,18 @@ static virStoragePoolObjPtr
testStoragePoolObjFindByName(testDriverPtr privconn, testStoragePoolObjFindByName(testDriverPtr privconn,
const char *name) const char *name)
{ {
virStoragePoolObjPtr pool; virStoragePoolObjPtr obj;
testDriverLock(privconn); testDriverLock(privconn);
pool = virStoragePoolObjFindByName(&privconn->pools, name); obj = virStoragePoolObjFindByName(&privconn->pools, name);
testDriverUnlock(privconn); testDriverUnlock(privconn);
if (!pool) if (!obj)
virReportError(VIR_ERR_NO_STORAGE_POOL, virReportError(VIR_ERR_NO_STORAGE_POOL,
_("no storage pool with matching name '%s'"), _("no storage pool with matching name '%s'"),
name); name);
return pool; return obj;
} }
...@@ -4073,21 +4072,21 @@ static virStoragePoolObjPtr ...@@ -4073,21 +4072,21 @@ static virStoragePoolObjPtr
testStoragePoolObjFindByUUID(testDriverPtr privconn, testStoragePoolObjFindByUUID(testDriverPtr privconn,
const unsigned char *uuid) const unsigned char *uuid)
{ {
virStoragePoolObjPtr pool; virStoragePoolObjPtr obj;
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
testDriverLock(privconn); testDriverLock(privconn);
pool = virStoragePoolObjFindByUUID(&privconn->pools, uuid); obj = virStoragePoolObjFindByUUID(&privconn->pools, uuid);
testDriverUnlock(privconn); testDriverUnlock(privconn);
if (!pool) { if (!obj) {
virUUIDFormat(uuid, uuidstr); virUUIDFormat(uuid, uuidstr);
virReportError(VIR_ERR_NO_STORAGE_POOL, virReportError(VIR_ERR_NO_STORAGE_POOL,
_("no storage pool with matching uuid '%s'"), _("no storage pool with matching uuid '%s'"),
uuidstr); uuidstr);
} }
return pool; return obj;
} }
...@@ -4096,19 +4095,19 @@ testStoragePoolLookupByUUID(virConnectPtr conn, ...@@ -4096,19 +4095,19 @@ testStoragePoolLookupByUUID(virConnectPtr conn,
const unsigned char *uuid) const unsigned char *uuid)
{ {
testDriverPtr privconn = conn->privateData; testDriverPtr privconn = conn->privateData;
virStoragePoolObjPtr pool; virStoragePoolObjPtr obj;
virStoragePoolPtr ret = NULL; virStoragePoolPtr pool = NULL;
if (!(pool = testStoragePoolObjFindByUUID(privconn, uuid))) if (!(obj = testStoragePoolObjFindByUUID(privconn, uuid)))
goto cleanup; goto cleanup;
ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid, pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid,
NULL, NULL); NULL, NULL);
cleanup: cleanup:
if (pool) if (obj)
virStoragePoolObjUnlock(pool); virStoragePoolObjUnlock(obj);
return ret; return pool;
} }
...@@ -4117,19 +4116,19 @@ testStoragePoolLookupByName(virConnectPtr conn, ...@@ -4117,19 +4116,19 @@ testStoragePoolLookupByName(virConnectPtr conn,
const char *name) const char *name)
{ {
testDriverPtr privconn = conn->privateData; testDriverPtr privconn = conn->privateData;
virStoragePoolObjPtr pool; virStoragePoolObjPtr obj;
virStoragePoolPtr ret = NULL; virStoragePoolPtr pool = NULL;
if (!(pool = testStoragePoolObjFindByName(privconn, name))) if (!(obj = testStoragePoolObjFindByName(privconn, name)))
goto cleanup; goto cleanup;
ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid, pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid,
NULL, NULL); NULL, NULL);
cleanup: cleanup:
if (pool) if (obj)
virStoragePoolObjUnlock(pool); virStoragePoolObjUnlock(obj);
return ret; return pool;
} }
...@@ -4266,22 +4265,22 @@ testStoragePoolCreate(virStoragePoolPtr pool, ...@@ -4266,22 +4265,22 @@ testStoragePoolCreate(virStoragePoolPtr pool,
unsigned int flags) unsigned int flags)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
int ret = -1; int ret = -1;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
virCheckFlags(0, -1); virCheckFlags(0, -1);
if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup; goto cleanup;
if (virStoragePoolObjIsActive(privpool)) { if (virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is already active"), pool->name); _("storage pool '%s' is already active"), pool->name);
goto cleanup; goto cleanup;
} }
privpool->active = 1; obj->active = 1;
event = virStoragePoolEventLifecycleNew(pool->name, pool->uuid, event = virStoragePoolEventLifecycleNew(pool->name, pool->uuid,
VIR_STORAGE_POOL_EVENT_STARTED, VIR_STORAGE_POOL_EVENT_STARTED,
...@@ -4290,8 +4289,8 @@ testStoragePoolCreate(virStoragePoolPtr pool, ...@@ -4290,8 +4289,8 @@ testStoragePoolCreate(virStoragePoolPtr pool,
cleanup: cleanup:
testObjectEventQueue(privconn, event); testObjectEventQueue(privconn, event);
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -4384,8 +4383,8 @@ testStoragePoolCreateXML(virConnectPtr conn, ...@@ -4384,8 +4383,8 @@ testStoragePoolCreateXML(virConnectPtr conn,
{ {
testDriverPtr privconn = conn->privateData; testDriverPtr privconn = conn->privateData;
virStoragePoolDefPtr def; virStoragePoolDefPtr def;
virStoragePoolObjPtr pool = NULL; virStoragePoolObjPtr obj = NULL;
virStoragePoolPtr ret = NULL; virStoragePoolPtr pool = NULL;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
...@@ -4394,60 +4393,59 @@ testStoragePoolCreateXML(virConnectPtr conn, ...@@ -4394,60 +4393,59 @@ testStoragePoolCreateXML(virConnectPtr conn,
if (!(def = virStoragePoolDefParseString(xml))) if (!(def = virStoragePoolDefParseString(xml)))
goto cleanup; goto cleanup;
pool = virStoragePoolObjFindByUUID(&privconn->pools, def->uuid); obj = virStoragePoolObjFindByUUID(&privconn->pools, def->uuid);
if (!pool) if (!obj)
pool = virStoragePoolObjFindByName(&privconn->pools, def->name); obj = virStoragePoolObjFindByName(&privconn->pools, def->name);
if (pool) { 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 (!(pool = virStoragePoolObjAssignDef(&privconn->pools, def))) if (!(obj = virStoragePoolObjAssignDef(&privconn->pools, def)))
goto cleanup; goto cleanup;
def = NULL; def = NULL;
if (pool->def->source.adapter.type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { if (obj->def->source.adapter.type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST) {
/* In the real code, we'd call virVHBAManageVport followed by /* In the real code, we'd call virVHBAManageVport followed by
* find_new_device, but we cannot do that here since we're not * find_new_device, but we cannot do that here since we're not
* mocking udev. The mock routine will copy an existing vHBA and * mocking udev. The mock routine will copy an existing vHBA and
* rename a few fields to mock that. */ * rename a few fields to mock that. */
if (testCreateVport(privconn, if (testCreateVport(privconn,
pool->def->source.adapter.data.fchost.wwnn, obj->def->source.adapter.data.fchost.wwnn,
pool->def->source.adapter.data.fchost.wwpn) < 0) { obj->def->source.adapter.data.fchost.wwpn) < 0) {
virStoragePoolObjRemove(&privconn->pools, pool); virStoragePoolObjRemove(&privconn->pools, obj);
pool = NULL; obj = NULL;
goto cleanup; goto cleanup;
} }
} }
if (testStoragePoolObjSetDefaults(pool) == -1) { if (testStoragePoolObjSetDefaults(obj) == -1) {
virStoragePoolObjRemove(&privconn->pools, pool); virStoragePoolObjRemove(&privconn->pools, obj);
pool = NULL; obj = NULL;
goto cleanup; goto cleanup;
} }
/* *SetDefaults fills this in for the persistent pools, but this /* *SetDefaults fills this in for the persistent pools, but this
* would be a transient pool so remove it; otherwise, the Destroy * would be a transient pool so remove it; otherwise, the Destroy
* code will not Remove the pool */ * code will not Remove the pool */
VIR_FREE(pool->configFile); VIR_FREE(obj->configFile);
pool->active = 1; obj->active = 1;
event = virStoragePoolEventLifecycleNew(pool->def->name, pool->def->uuid, event = virStoragePoolEventLifecycleNew(obj->def->name, obj->def->uuid,
VIR_STORAGE_POOL_EVENT_STARTED, VIR_STORAGE_POOL_EVENT_STARTED,
0); 0);
ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid, pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL, NULL);
NULL, NULL);
cleanup: cleanup:
virStoragePoolDefFree(def); virStoragePoolDefFree(def);
testObjectEventQueue(privconn, event); testObjectEventQueue(privconn, event);
if (pool) if (obj)
virStoragePoolObjUnlock(pool); virStoragePoolObjUnlock(obj);
testDriverUnlock(privconn); testDriverUnlock(privconn);
return ret; return pool;
} }
...@@ -4458,8 +4456,8 @@ testStoragePoolDefineXML(virConnectPtr conn, ...@@ -4458,8 +4456,8 @@ testStoragePoolDefineXML(virConnectPtr conn,
{ {
testDriverPtr privconn = conn->privateData; testDriverPtr privconn = conn->privateData;
virStoragePoolDefPtr def; virStoragePoolDefPtr def;
virStoragePoolObjPtr pool = NULL; virStoragePoolObjPtr obj = NULL;
virStoragePoolPtr ret = NULL; virStoragePoolPtr pool = NULL;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
...@@ -4472,30 +4470,29 @@ testStoragePoolDefineXML(virConnectPtr conn, ...@@ -4472,30 +4470,29 @@ testStoragePoolDefineXML(virConnectPtr conn,
def->allocation = defaultPoolAlloc; def->allocation = defaultPoolAlloc;
def->available = defaultPoolCap - defaultPoolAlloc; def->available = defaultPoolCap - defaultPoolAlloc;
if (!(pool = virStoragePoolObjAssignDef(&privconn->pools, def))) if (!(obj = virStoragePoolObjAssignDef(&privconn->pools, def)))
goto cleanup; goto cleanup;
def = NULL; def = NULL;
event = virStoragePoolEventLifecycleNew(pool->def->name, pool->def->uuid, event = virStoragePoolEventLifecycleNew(obj->def->name, obj->def->uuid,
VIR_STORAGE_POOL_EVENT_DEFINED, VIR_STORAGE_POOL_EVENT_DEFINED,
0); 0);
if (testStoragePoolObjSetDefaults(pool) == -1) { if (testStoragePoolObjSetDefaults(obj) == -1) {
virStoragePoolObjRemove(&privconn->pools, pool); virStoragePoolObjRemove(&privconn->pools, obj);
pool = NULL; obj = NULL;
goto cleanup; goto cleanup;
} }
ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid, pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL, NULL);
NULL, NULL);
cleanup: cleanup:
virStoragePoolDefFree(def); virStoragePoolDefFree(def);
testObjectEventQueue(privconn, event); testObjectEventQueue(privconn, event);
if (pool) if (obj)
virStoragePoolObjUnlock(pool); virStoragePoolObjUnlock(obj);
testDriverUnlock(privconn); testDriverUnlock(privconn);
return ret; return pool;
} }
...@@ -4503,14 +4500,14 @@ static int ...@@ -4503,14 +4500,14 @@ static int
testStoragePoolUndefine(virStoragePoolPtr pool) testStoragePoolUndefine(virStoragePoolPtr pool)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
int ret = -1; int ret = -1;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup; goto cleanup;
if (virStoragePoolObjIsActive(privpool)) { if (virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is already active"), pool->name); _("storage pool '%s' is already active"), pool->name);
goto cleanup; goto cleanup;
...@@ -4520,13 +4517,13 @@ testStoragePoolUndefine(virStoragePoolPtr pool) ...@@ -4520,13 +4517,13 @@ testStoragePoolUndefine(virStoragePoolPtr pool)
VIR_STORAGE_POOL_EVENT_UNDEFINED, VIR_STORAGE_POOL_EVENT_UNDEFINED,
0); 0);
virStoragePoolObjRemove(&privconn->pools, privpool); virStoragePoolObjRemove(&privconn->pools, obj);
privpool = NULL; obj = NULL;
ret = 0; ret = 0;
cleanup: cleanup:
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
testObjectEventQueue(privconn, event); testObjectEventQueue(privconn, event);
return ret; return ret;
} }
...@@ -4537,15 +4534,15 @@ testStoragePoolBuild(virStoragePoolPtr pool, ...@@ -4537,15 +4534,15 @@ testStoragePoolBuild(virStoragePoolPtr pool,
unsigned int flags) unsigned int flags)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
int ret = -1; int ret = -1;
virCheckFlags(0, -1); virCheckFlags(0, -1);
if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup; goto cleanup;
if (virStoragePoolObjIsActive(privpool)) { if (virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is already active"), pool->name); _("storage pool '%s' is already active"), pool->name);
goto cleanup; goto cleanup;
...@@ -4553,8 +4550,8 @@ testStoragePoolBuild(virStoragePoolPtr pool, ...@@ -4553,8 +4550,8 @@ testStoragePoolBuild(virStoragePoolPtr pool,
ret = 0; ret = 0;
cleanup: cleanup:
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -4597,44 +4594,44 @@ static int ...@@ -4597,44 +4594,44 @@ static int
testStoragePoolDestroy(virStoragePoolPtr pool) testStoragePoolDestroy(virStoragePoolPtr pool)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
int ret = -1; int ret = -1;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
return -1; return -1;
if (!virStoragePoolObjIsActive(privpool)) { if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->name); _("storage pool '%s' is not active"), pool->name);
goto cleanup; goto cleanup;
} }
privpool->active = 0; obj->active = 0;
if (privpool->def->source.adapter.type == if (obj->def->source.adapter.type ==
VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { VIR_STORAGE_ADAPTER_TYPE_FC_HOST) {
if (testDestroyVport(privconn, if (testDestroyVport(privconn,
privpool->def->source.adapter.data.fchost.wwnn, obj->def->source.adapter.data.fchost.wwnn,
privpool->def->source.adapter.data.fchost.wwpn) < 0) obj->def->source.adapter.data.fchost.wwpn) < 0)
goto cleanup; goto cleanup;
} }
event = virStoragePoolEventLifecycleNew(privpool->def->name, event = virStoragePoolEventLifecycleNew(obj->def->name,
privpool->def->uuid, obj->def->uuid,
VIR_STORAGE_POOL_EVENT_STOPPED, VIR_STORAGE_POOL_EVENT_STOPPED,
0); 0);
if (privpool->configFile == NULL) { if (obj->configFile == NULL) {
virStoragePoolObjRemove(&privconn->pools, privpool); virStoragePoolObjRemove(&privconn->pools, obj);
privpool = NULL; obj = NULL;
} }
ret = 0; ret = 0;
cleanup: cleanup:
testObjectEventQueue(privconn, event); testObjectEventQueue(privconn, event);
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -4644,15 +4641,15 @@ testStoragePoolDelete(virStoragePoolPtr pool, ...@@ -4644,15 +4641,15 @@ testStoragePoolDelete(virStoragePoolPtr pool,
unsigned int flags) unsigned int flags)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
int ret = -1; int ret = -1;
virCheckFlags(0, -1); virCheckFlags(0, -1);
if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup; goto cleanup;
if (virStoragePoolObjIsActive(privpool)) { if (virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is already active"), pool->name); _("storage pool '%s' is already active"), pool->name);
goto cleanup; goto cleanup;
...@@ -4661,8 +4658,8 @@ testStoragePoolDelete(virStoragePoolPtr pool, ...@@ -4661,8 +4658,8 @@ testStoragePoolDelete(virStoragePoolPtr pool,
ret = 0; ret = 0;
cleanup: cleanup:
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -4672,16 +4669,16 @@ testStoragePoolRefresh(virStoragePoolPtr pool, ...@@ -4672,16 +4669,16 @@ testStoragePoolRefresh(virStoragePoolPtr pool,
unsigned int flags) unsigned int flags)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
int ret = -1; int ret = -1;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
virCheckFlags(0, -1); virCheckFlags(0, -1);
if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup; goto cleanup;
if (!virStoragePoolObjIsActive(privpool)) { if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->name); _("storage pool '%s' is not active"), pool->name);
goto cleanup; goto cleanup;
...@@ -4692,8 +4689,8 @@ testStoragePoolRefresh(virStoragePoolPtr pool, ...@@ -4692,8 +4689,8 @@ testStoragePoolRefresh(virStoragePoolPtr pool,
cleanup: cleanup:
testObjectEventQueue(privconn, event); testObjectEventQueue(privconn, event);
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -4703,25 +4700,25 @@ testStoragePoolGetInfo(virStoragePoolPtr pool, ...@@ -4703,25 +4700,25 @@ testStoragePoolGetInfo(virStoragePoolPtr pool,
virStoragePoolInfoPtr info) virStoragePoolInfoPtr info)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
int ret = -1; int ret = -1;
if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup; goto cleanup;
memset(info, 0, sizeof(virStoragePoolInfo)); memset(info, 0, sizeof(virStoragePoolInfo));
if (privpool->active) if (obj->active)
info->state = VIR_STORAGE_POOL_RUNNING; info->state = VIR_STORAGE_POOL_RUNNING;
else else
info->state = VIR_STORAGE_POOL_INACTIVE; info->state = VIR_STORAGE_POOL_INACTIVE;
info->capacity = privpool->def->capacity; info->capacity = obj->def->capacity;
info->allocation = privpool->def->allocation; info->allocation = obj->def->allocation;
info->available = privpool->def->available; info->available = obj->def->available;
ret = 0; ret = 0;
cleanup: cleanup:
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -4731,19 +4728,19 @@ testStoragePoolGetXMLDesc(virStoragePoolPtr pool, ...@@ -4731,19 +4728,19 @@ testStoragePoolGetXMLDesc(virStoragePoolPtr pool,
unsigned int flags) unsigned int flags)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
char *ret = NULL; char *ret = NULL;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup; goto cleanup;
ret = virStoragePoolDefFormat(privpool->def); ret = virStoragePoolDefFormat(obj->def);
cleanup: cleanup:
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -4753,22 +4750,22 @@ testStoragePoolGetAutostart(virStoragePoolPtr pool, ...@@ -4753,22 +4750,22 @@ testStoragePoolGetAutostart(virStoragePoolPtr pool,
int *autostart) int *autostart)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
int ret = -1; int ret = -1;
if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup; goto cleanup;
if (!privpool->configFile) { if (!obj->configFile) {
*autostart = 0; *autostart = 0;
} else { } else {
*autostart = privpool->autostart; *autostart = obj->autostart;
} }
ret = 0; ret = 0;
cleanup: cleanup:
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -4778,25 +4775,25 @@ testStoragePoolSetAutostart(virStoragePoolPtr pool, ...@@ -4778,25 +4775,25 @@ testStoragePoolSetAutostart(virStoragePoolPtr pool,
int autostart) int autostart)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
int ret = -1; int ret = -1;
if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup; goto cleanup;
if (!privpool->configFile) { if (!obj->configFile) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
"%s", _("pool has no config file")); "%s", _("pool has no config file"));
goto cleanup; goto cleanup;
} }
autostart = (autostart != 0); autostart = (autostart != 0);
privpool->autostart = autostart; obj->autostart = autostart;
ret = 0; ret = 0;
cleanup: cleanup:
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -4805,24 +4802,24 @@ static int ...@@ -4805,24 +4802,24 @@ static int
testStoragePoolNumOfVolumes(virStoragePoolPtr pool) testStoragePoolNumOfVolumes(virStoragePoolPtr pool)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
int ret = -1; int ret = -1;
if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup; goto cleanup;
if (!virStoragePoolObjIsActive(privpool)) { if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->name); _("storage pool '%s' is not active"), pool->name);
goto cleanup; goto cleanup;
} }
ret = virStoragePoolObjNumOfVolumes(&privpool->volumes, pool->conn, ret = virStoragePoolObjNumOfVolumes(&obj->volumes, pool->conn,
privpool->def, NULL); obj->def, NULL);
cleanup: cleanup:
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -4833,52 +4830,52 @@ testStoragePoolListVolumes(virStoragePoolPtr pool, ...@@ -4833,52 +4830,52 @@ testStoragePoolListVolumes(virStoragePoolPtr pool,
int maxnames) int maxnames)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
int n = -1; int n = -1;
if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
return -1; return -1;
if (!virStoragePoolObjIsActive(privpool)) { if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->name); _("storage pool '%s' is not active"), pool->name);
goto cleanup; goto cleanup;
} }
n = virStoragePoolObjVolumeGetNames(&privpool->volumes, pool->conn, n = virStoragePoolObjVolumeGetNames(&obj->volumes, pool->conn,
privpool->def, NULL, names, maxnames); obj->def, NULL, names, maxnames);
cleanup: cleanup:
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return n; return n;
} }
static int static int
testStoragePoolListAllVolumes(virStoragePoolPtr obj, testStoragePoolListAllVolumes(virStoragePoolPtr pool,
virStorageVolPtr **vols, virStorageVolPtr **vols,
unsigned int flags) unsigned int flags)
{ {
testDriverPtr privconn = obj->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr pool; virStoragePoolObjPtr obj;
int ret = -1; int ret = -1;
virCheckFlags(0, -1); virCheckFlags(0, -1);
if (!(pool = testStoragePoolObjFindByUUID(privconn, obj->uuid))) if (!(obj = testStoragePoolObjFindByUUID(privconn, pool->uuid)))
return -1; return -1;
if (!virStoragePoolObjIsActive(pool)) { if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("storage pool is not active")); _("storage pool is not active"));
goto cleanup; goto cleanup;
} }
ret = virStoragePoolObjVolumeListExport(obj->conn, &pool->volumes, ret = virStoragePoolObjVolumeListExport(pool->conn, &obj->volumes,
pool->def, vols, NULL); obj->def, vols, NULL);
cleanup: cleanup:
virStoragePoolObjUnlock(pool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -4889,20 +4886,20 @@ testStorageVolLookupByName(virStoragePoolPtr pool, ...@@ -4889,20 +4886,20 @@ testStorageVolLookupByName(virStoragePoolPtr pool,
const char *name ATTRIBUTE_UNUSED) const char *name ATTRIBUTE_UNUSED)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
virStorageVolDefPtr privvol; virStorageVolDefPtr privvol;
virStorageVolPtr ret = NULL; virStorageVolPtr ret = NULL;
if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup; goto cleanup;
if (!virStoragePoolObjIsActive(privpool)) { if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->name); _("storage pool '%s' is not active"), pool->name);
goto cleanup; goto cleanup;
} }
privvol = virStorageVolDefFindByName(privpool, name); privvol = virStorageVolDefFindByName(obj, name);
if (!privvol) { if (!privvol) {
virReportError(VIR_ERR_NO_STORAGE_VOL, virReportError(VIR_ERR_NO_STORAGE_VOL,
...@@ -4910,13 +4907,13 @@ testStorageVolLookupByName(virStoragePoolPtr pool, ...@@ -4910,13 +4907,13 @@ testStorageVolLookupByName(virStoragePoolPtr pool,
goto cleanup; goto cleanup;
} }
ret = virGetStorageVol(pool->conn, privpool->def->name, ret = virGetStorageVol(pool->conn, obj->def->name,
privvol->name, privvol->key, privvol->name, privvol->key,
NULL, NULL); NULL, NULL);
cleanup: cleanup:
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -5001,34 +4998,34 @@ testStorageVolCreateXML(virStoragePoolPtr pool, ...@@ -5001,34 +4998,34 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
unsigned int flags) unsigned int flags)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
virStorageVolDefPtr privvol = NULL; virStorageVolDefPtr privvol = NULL;
virStorageVolPtr ret = NULL; virStorageVolPtr ret = NULL;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup; goto cleanup;
if (!virStoragePoolObjIsActive(privpool)) { if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->name); _("storage pool '%s' is not active"), pool->name);
goto cleanup; goto cleanup;
} }
privvol = virStorageVolDefParseString(privpool->def, xmldesc, 0); privvol = virStorageVolDefParseString(obj->def, xmldesc, 0);
if (privvol == NULL) if (privvol == NULL)
goto cleanup; goto cleanup;
if (virStorageVolDefFindByName(privpool, privvol->name)) { if (virStorageVolDefFindByName(obj, privvol->name)) {
virReportError(VIR_ERR_OPERATION_FAILED, virReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("storage vol already exists")); "%s", _("storage vol already exists"));
goto cleanup; goto cleanup;
} }
/* Make sure enough space */ /* Make sure enough space */
if ((privpool->def->allocation + privvol->target.allocation) > if ((obj->def->allocation + privvol->target.allocation) >
privpool->def->capacity) { obj->def->capacity) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Not enough free space in pool for volume '%s'"), _("Not enough free space in pool for volume '%s'"),
privvol->name); privvol->name);
...@@ -5036,28 +5033,27 @@ testStorageVolCreateXML(virStoragePoolPtr pool, ...@@ -5036,28 +5033,27 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
} }
if (virAsprintf(&privvol->target.path, "%s/%s", if (virAsprintf(&privvol->target.path, "%s/%s",
privpool->def->target.path, obj->def->target.path,
privvol->name) == -1) privvol->name) == -1)
goto cleanup; goto cleanup;
if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 ||
VIR_APPEND_ELEMENT_COPY(privpool->volumes.objs, VIR_APPEND_ELEMENT_COPY(obj->volumes.objs,
privpool->volumes.count, privvol) < 0) obj->volumes.count, privvol) < 0)
goto cleanup; goto cleanup;
privpool->def->allocation += privvol->target.allocation; obj->def->allocation += privvol->target.allocation;
privpool->def->available = (privpool->def->capacity - obj->def->available = (obj->def->capacity - obj->def->allocation);
privpool->def->allocation);
ret = virGetStorageVol(pool->conn, privpool->def->name, ret = virGetStorageVol(pool->conn, obj->def->name,
privvol->name, privvol->key, privvol->name, privvol->key,
NULL, NULL); NULL, NULL);
privvol = NULL; privvol = NULL;
cleanup: cleanup:
virStorageVolDefFree(privvol); virStorageVolDefFree(privvol);
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -5069,32 +5065,32 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, ...@@ -5069,32 +5065,32 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
unsigned int flags) unsigned int flags)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
virStorageVolDefPtr privvol = NULL, origvol = NULL; virStorageVolDefPtr privvol = NULL, origvol = NULL;
virStorageVolPtr ret = NULL; virStorageVolPtr ret = NULL;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup; goto cleanup;
if (!virStoragePoolObjIsActive(privpool)) { if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->name); _("storage pool '%s' is not active"), pool->name);
goto cleanup; goto cleanup;
} }
privvol = virStorageVolDefParseString(privpool->def, xmldesc, 0); privvol = virStorageVolDefParseString(obj->def, xmldesc, 0);
if (privvol == NULL) if (privvol == NULL)
goto cleanup; goto cleanup;
if (virStorageVolDefFindByName(privpool, privvol->name)) { if (virStorageVolDefFindByName(obj, privvol->name)) {
virReportError(VIR_ERR_OPERATION_FAILED, virReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("storage vol already exists")); "%s", _("storage vol already exists"));
goto cleanup; goto cleanup;
} }
origvol = virStorageVolDefFindByName(privpool, clonevol->name); origvol = virStorageVolDefFindByName(obj, clonevol->name);
if (!origvol) { if (!origvol) {
virReportError(VIR_ERR_NO_STORAGE_VOL, virReportError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"), _("no storage vol with matching name '%s'"),
...@@ -5103,39 +5099,37 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, ...@@ -5103,39 +5099,37 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
} }
/* Make sure enough space */ /* Make sure enough space */
if ((privpool->def->allocation + privvol->target.allocation) > if ((obj->def->allocation + privvol->target.allocation) >
privpool->def->capacity) { obj->def->capacity) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Not enough free space in pool for volume '%s'"), _("Not enough free space in pool for volume '%s'"),
privvol->name); privvol->name);
goto cleanup; goto cleanup;
} }
privpool->def->available = (privpool->def->capacity - obj->def->available = (obj->def->capacity - obj->def->allocation);
privpool->def->allocation);
if (virAsprintf(&privvol->target.path, "%s/%s", if (virAsprintf(&privvol->target.path, "%s/%s",
privpool->def->target.path, obj->def->target.path,
privvol->name) == -1) privvol->name) == -1)
goto cleanup; goto cleanup;
if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 ||
VIR_APPEND_ELEMENT_COPY(privpool->volumes.objs, VIR_APPEND_ELEMENT_COPY(obj->volumes.objs,
privpool->volumes.count, privvol) < 0) obj->volumes.count, privvol) < 0)
goto cleanup; goto cleanup;
privpool->def->allocation += privvol->target.allocation; obj->def->allocation += privvol->target.allocation;
privpool->def->available = (privpool->def->capacity - obj->def->available = (obj->def->capacity - obj->def->allocation);
privpool->def->allocation);
ret = virGetStorageVol(pool->conn, privpool->def->name, ret = virGetStorageVol(pool->conn, obj->def->name,
privvol->name, privvol->key, privvol->name, privvol->key,
NULL, NULL); NULL, NULL);
privvol = NULL; privvol = NULL;
cleanup: cleanup:
virStorageVolDefFree(privvol); virStorageVolDefFree(privvol);
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -5145,17 +5139,17 @@ testStorageVolDelete(virStorageVolPtr vol, ...@@ -5145,17 +5139,17 @@ testStorageVolDelete(virStorageVolPtr vol,
unsigned int flags) unsigned int flags)
{ {
testDriverPtr privconn = vol->conn->privateData; testDriverPtr privconn = vol->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
virStorageVolDefPtr privvol; virStorageVolDefPtr privvol;
size_t i; size_t i;
int ret = -1; int ret = -1;
virCheckFlags(0, -1); virCheckFlags(0, -1);
if (!(privpool = testStoragePoolObjFindByName(privconn, vol->pool))) if (!(obj = testStoragePoolObjFindByName(privconn, vol->pool)))
goto cleanup; goto cleanup;
privvol = virStorageVolDefFindByName(privpool, vol->name); privvol = virStorageVolDefFindByName(obj, vol->name);
if (privvol == NULL) { if (privvol == NULL) {
virReportError(VIR_ERR_NO_STORAGE_VOL, virReportError(VIR_ERR_NO_STORAGE_VOL,
...@@ -5164,30 +5158,29 @@ testStorageVolDelete(virStorageVolPtr vol, ...@@ -5164,30 +5158,29 @@ testStorageVolDelete(virStorageVolPtr vol,
goto cleanup; goto cleanup;
} }
if (!virStoragePoolObjIsActive(privpool)) { if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), vol->pool); _("storage pool '%s' is not active"), vol->pool);
goto cleanup; goto cleanup;
} }
privpool->def->allocation -= privvol->target.allocation; obj->def->allocation -= privvol->target.allocation;
privpool->def->available = (privpool->def->capacity - obj->def->available = (obj->def->capacity - obj->def->allocation);
privpool->def->allocation);
for (i = 0; i < privpool->volumes.count; i++) { for (i = 0; i < obj->volumes.count; i++) {
if (privpool->volumes.objs[i] == privvol) { if (obj->volumes.objs[i] == privvol) {
virStorageVolDefFree(privvol); virStorageVolDefFree(privvol);
VIR_DELETE_ELEMENT(privpool->volumes.objs, i, privpool->volumes.count); VIR_DELETE_ELEMENT(obj->volumes.objs, i, obj->volumes.count);
break; break;
} }
} }
ret = 0; ret = 0;
cleanup: cleanup:
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -5212,14 +5205,14 @@ testStorageVolGetInfo(virStorageVolPtr vol, ...@@ -5212,14 +5205,14 @@ testStorageVolGetInfo(virStorageVolPtr vol,
virStorageVolInfoPtr info) virStorageVolInfoPtr info)
{ {
testDriverPtr privconn = vol->conn->privateData; testDriverPtr privconn = vol->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
virStorageVolDefPtr privvol; virStorageVolDefPtr privvol;
int ret = -1; int ret = -1;
if (!(privpool = testStoragePoolObjFindByName(privconn, vol->pool))) if (!(obj = testStoragePoolObjFindByName(privconn, vol->pool)))
goto cleanup; goto cleanup;
privvol = virStorageVolDefFindByName(privpool, vol->name); privvol = virStorageVolDefFindByName(obj, vol->name);
if (privvol == NULL) { if (privvol == NULL) {
virReportError(VIR_ERR_NO_STORAGE_VOL, virReportError(VIR_ERR_NO_STORAGE_VOL,
...@@ -5228,21 +5221,21 @@ testStorageVolGetInfo(virStorageVolPtr vol, ...@@ -5228,21 +5221,21 @@ testStorageVolGetInfo(virStorageVolPtr vol,
goto cleanup; goto cleanup;
} }
if (!virStoragePoolObjIsActive(privpool)) { if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), vol->pool); _("storage pool '%s' is not active"), vol->pool);
goto cleanup; goto cleanup;
} }
memset(info, 0, sizeof(*info)); memset(info, 0, sizeof(*info));
info->type = testStorageVolumeTypeForPool(privpool->def->type); info->type = testStorageVolumeTypeForPool(obj->def->type);
info->capacity = privvol->target.capacity; info->capacity = privvol->target.capacity;
info->allocation = privvol->target.allocation; info->allocation = privvol->target.allocation;
ret = 0; ret = 0;
cleanup: cleanup:
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -5252,16 +5245,16 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol, ...@@ -5252,16 +5245,16 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol,
unsigned int flags) unsigned int flags)
{ {
testDriverPtr privconn = vol->conn->privateData; testDriverPtr privconn = vol->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
virStorageVolDefPtr privvol; virStorageVolDefPtr privvol;
char *ret = NULL; char *ret = NULL;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
if (!(privpool = testStoragePoolObjFindByName(privconn, vol->pool))) if (!(obj = testStoragePoolObjFindByName(privconn, vol->pool)))
goto cleanup; goto cleanup;
privvol = virStorageVolDefFindByName(privpool, vol->name); privvol = virStorageVolDefFindByName(obj, vol->name);
if (privvol == NULL) { if (privvol == NULL) {
virReportError(VIR_ERR_NO_STORAGE_VOL, virReportError(VIR_ERR_NO_STORAGE_VOL,
...@@ -5270,17 +5263,17 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol, ...@@ -5270,17 +5263,17 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol,
goto cleanup; goto cleanup;
} }
if (!virStoragePoolObjIsActive(privpool)) { if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), vol->pool); _("storage pool '%s' is not active"), vol->pool);
goto cleanup; goto cleanup;
} }
ret = virStorageVolDefFormat(privpool->def, privvol); ret = virStorageVolDefFormat(obj->def, privvol);
cleanup: cleanup:
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
...@@ -5289,14 +5282,14 @@ static char * ...@@ -5289,14 +5282,14 @@ static char *
testStorageVolGetPath(virStorageVolPtr vol) testStorageVolGetPath(virStorageVolPtr vol)
{ {
testDriverPtr privconn = vol->conn->privateData; testDriverPtr privconn = vol->conn->privateData;
virStoragePoolObjPtr privpool; virStoragePoolObjPtr obj;
virStorageVolDefPtr privvol; virStorageVolDefPtr privvol;
char *ret = NULL; char *ret = NULL;
if (!(privpool = testStoragePoolObjFindByName(privconn, vol->pool))) if (!(obj = testStoragePoolObjFindByName(privconn, vol->pool)))
goto cleanup; goto cleanup;
privvol = virStorageVolDefFindByName(privpool, vol->name); privvol = virStorageVolDefFindByName(obj, vol->name);
if (privvol == NULL) { if (privvol == NULL) {
virReportError(VIR_ERR_NO_STORAGE_VOL, virReportError(VIR_ERR_NO_STORAGE_VOL,
...@@ -5305,7 +5298,7 @@ testStorageVolGetPath(virStorageVolPtr vol) ...@@ -5305,7 +5298,7 @@ testStorageVolGetPath(virStorageVolPtr vol)
goto cleanup; goto cleanup;
} }
if (!virStoragePoolObjIsActive(privpool)) { if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID, virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), vol->pool); _("storage pool '%s' is not active"), vol->pool);
goto cleanup; goto cleanup;
...@@ -5314,8 +5307,8 @@ testStorageVolGetPath(virStorageVolPtr vol) ...@@ -5314,8 +5307,8 @@ testStorageVolGetPath(virStorageVolPtr vol)
ignore_value(VIR_STRDUP(ret, privvol->target.path)); ignore_value(VIR_STRDUP(ret, privvol->target.path));
cleanup: cleanup:
if (privpool) if (obj)
virStoragePoolObjUnlock(privpool); virStoragePoolObjUnlock(obj);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册