mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 06:25:19 +00:00
test: Add helpers to fetch active/inactive storage pool by name
Rather than have repetitive code - create/use a couple of helpers: testStoragePoolObjFindActiveByName testStoragePoolObjFindInactiveByName This will also allow for the reduction of some cleanup path logic. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
b5e0fa41e2
commit
0e18356271
@ -4068,6 +4068,46 @@ testStoragePoolObjFindByName(testDriverPtr privconn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static virStoragePoolObjPtr
|
||||||
|
testStoragePoolObjFindActiveByName(testDriverPtr privconn,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
virStoragePoolObjPtr obj;
|
||||||
|
|
||||||
|
if (!(obj = testStoragePoolObjFindByName(privconn, name)))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!virStoragePoolObjIsActive(obj)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
|
_("storage pool '%s' is not active"), name);
|
||||||
|
virStoragePoolObjUnlock(obj);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static virStoragePoolObjPtr
|
||||||
|
testStoragePoolObjFindInactiveByName(testDriverPtr privconn,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
virStoragePoolObjPtr obj;
|
||||||
|
|
||||||
|
if (!(obj = testStoragePoolObjFindByName(privconn, name)))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (virStoragePoolObjIsActive(obj)) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
|
_("storage pool '%s' is active"), name);
|
||||||
|
virStoragePoolObjUnlock(obj);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static virStoragePoolObjPtr
|
static virStoragePoolObjPtr
|
||||||
testStoragePoolObjFindByUUID(testDriverPtr privconn,
|
testStoragePoolObjFindByUUID(testDriverPtr privconn,
|
||||||
const unsigned char *uuid)
|
const unsigned char *uuid)
|
||||||
@ -4260,32 +4300,22 @@ testStoragePoolCreate(virStoragePoolPtr pool,
|
|||||||
{
|
{
|
||||||
testDriverPtr privconn = pool->conn->privateData;
|
testDriverPtr privconn = pool->conn->privateData;
|
||||||
virStoragePoolObjPtr obj;
|
virStoragePoolObjPtr obj;
|
||||||
int ret = -1;
|
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
|
if (!(obj = testStoragePoolObjFindInactiveByName(privconn, pool->name)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virStoragePoolObjIsActive(obj)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("storage pool '%s' is already active"), pool->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
obj->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,
|
||||||
0);
|
0);
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
testObjectEventQueue(privconn, event);
|
testObjectEventQueue(privconn, event);
|
||||||
if (obj)
|
virStoragePoolObjUnlock(obj);
|
||||||
virStoragePoolObjUnlock(obj);
|
return 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4495,31 +4525,19 @@ testStoragePoolUndefine(virStoragePoolPtr pool)
|
|||||||
{
|
{
|
||||||
testDriverPtr privconn = pool->conn->privateData;
|
testDriverPtr privconn = pool->conn->privateData;
|
||||||
virStoragePoolObjPtr obj;
|
virStoragePoolObjPtr obj;
|
||||||
int ret = -1;
|
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
|
|
||||||
if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
|
if (!(obj = testStoragePoolObjFindInactiveByName(privconn, pool->name)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virStoragePoolObjIsActive(obj)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("storage pool '%s' is already active"), pool->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
event = virStoragePoolEventLifecycleNew(pool->name, pool->uuid,
|
event = virStoragePoolEventLifecycleNew(pool->name, pool->uuid,
|
||||||
VIR_STORAGE_POOL_EVENT_UNDEFINED,
|
VIR_STORAGE_POOL_EVENT_UNDEFINED,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
virStoragePoolObjRemove(&privconn->pools, obj);
|
virStoragePoolObjRemove(&privconn->pools, obj);
|
||||||
obj = NULL;
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (obj)
|
|
||||||
virStoragePoolObjUnlock(obj);
|
|
||||||
testObjectEventQueue(privconn, event);
|
testObjectEventQueue(privconn, event);
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4529,24 +4547,14 @@ testStoragePoolBuild(virStoragePoolPtr pool,
|
|||||||
{
|
{
|
||||||
testDriverPtr privconn = pool->conn->privateData;
|
testDriverPtr privconn = pool->conn->privateData;
|
||||||
virStoragePoolObjPtr obj;
|
virStoragePoolObjPtr obj;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
|
if (!(obj = testStoragePoolObjFindInactiveByName(privconn, pool->name)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virStoragePoolObjIsActive(obj)) {
|
virStoragePoolObjUnlock(obj);
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
return 0;
|
||||||
_("storage pool '%s' is already active"), pool->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (obj)
|
|
||||||
virStoragePoolObjUnlock(obj);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4592,15 +4600,9 @@ testStoragePoolDestroy(virStoragePoolPtr pool)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
|
|
||||||
if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
|
if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!virStoragePoolObjIsActive(obj)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("storage pool '%s' is not active"), pool->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
obj->active = 0;
|
obj->active = 0;
|
||||||
|
|
||||||
if (obj->def->source.adapter.type ==
|
if (obj->def->source.adapter.type ==
|
||||||
@ -4636,25 +4638,14 @@ testStoragePoolDelete(virStoragePoolPtr pool,
|
|||||||
{
|
{
|
||||||
testDriverPtr privconn = pool->conn->privateData;
|
testDriverPtr privconn = pool->conn->privateData;
|
||||||
virStoragePoolObjPtr obj;
|
virStoragePoolObjPtr obj;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
|
if (!(obj = testStoragePoolObjFindInactiveByName(privconn, pool->name)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virStoragePoolObjIsActive(obj)) {
|
virStoragePoolObjUnlock(obj);
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
return 0;
|
||||||
_("storage pool '%s' is already active"), pool->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (obj)
|
|
||||||
virStoragePoolObjUnlock(obj);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4664,28 +4655,18 @@ testStoragePoolRefresh(virStoragePoolPtr pool,
|
|||||||
{
|
{
|
||||||
testDriverPtr privconn = pool->conn->privateData;
|
testDriverPtr privconn = pool->conn->privateData;
|
||||||
virStoragePoolObjPtr obj;
|
virStoragePoolObjPtr obj;
|
||||||
int ret = -1;
|
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
|
if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!virStoragePoolObjIsActive(obj)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("storage pool '%s' is not active"), pool->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
event = virStoragePoolEventRefreshNew(pool->name, pool->uuid);
|
event = virStoragePoolEventRefreshNew(pool->name, pool->uuid);
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
testObjectEventQueue(privconn, event);
|
testObjectEventQueue(privconn, event);
|
||||||
if (obj)
|
virStoragePoolObjUnlock(obj);
|
||||||
virStoragePoolObjUnlock(obj);
|
return 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4788,21 +4769,13 @@ testStoragePoolNumOfVolumes(virStoragePoolPtr pool)
|
|||||||
virStoragePoolObjPtr obj;
|
virStoragePoolObjPtr obj;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
|
if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!virStoragePoolObjIsActive(obj)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("storage pool '%s' is not active"), pool->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = virStoragePoolObjNumOfVolumes(&obj->volumes, pool->conn,
|
ret = virStoragePoolObjNumOfVolumes(&obj->volumes, pool->conn,
|
||||||
obj->def, NULL);
|
obj->def, NULL);
|
||||||
|
|
||||||
cleanup:
|
virStoragePoolObjUnlock(obj);
|
||||||
if (obj)
|
|
||||||
virStoragePoolObjUnlock(obj);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4816,19 +4789,12 @@ testStoragePoolListVolumes(virStoragePoolPtr pool,
|
|||||||
virStoragePoolObjPtr obj;
|
virStoragePoolObjPtr obj;
|
||||||
int n = -1;
|
int n = -1;
|
||||||
|
|
||||||
if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
|
if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!virStoragePoolObjIsActive(obj)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("storage pool '%s' is not active"), pool->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
n = virStoragePoolObjVolumeGetNames(&obj->volumes, pool->conn,
|
n = virStoragePoolObjVolumeGetNames(&obj->volumes, pool->conn,
|
||||||
obj->def, NULL, names, maxnames);
|
obj->def, NULL, names, maxnames);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virStoragePoolObjUnlock(obj);
|
virStoragePoolObjUnlock(obj);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -4873,14 +4839,8 @@ testStorageVolLookupByName(virStoragePoolPtr pool,
|
|||||||
virStorageVolDefPtr privvol;
|
virStorageVolDefPtr privvol;
|
||||||
virStorageVolPtr ret = NULL;
|
virStorageVolPtr ret = NULL;
|
||||||
|
|
||||||
if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
|
if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name)))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (!virStoragePoolObjIsActive(obj)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("storage pool '%s' is not active"), pool->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
privvol = virStorageVolDefFindByName(obj, name);
|
privvol = virStorageVolDefFindByName(obj, name);
|
||||||
|
|
||||||
@ -4895,8 +4855,7 @@ testStorageVolLookupByName(virStoragePoolPtr pool,
|
|||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (obj)
|
virStoragePoolObjUnlock(obj);
|
||||||
virStoragePoolObjUnlock(obj);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4987,14 +4946,8 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
|
if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name)))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (!virStoragePoolObjIsActive(obj)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("storage pool '%s' is not active"), pool->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
privvol = virStorageVolDefParseString(obj->def, xmldesc, 0);
|
privvol = virStorageVolDefParseString(obj->def, xmldesc, 0);
|
||||||
if (privvol == NULL)
|
if (privvol == NULL)
|
||||||
@ -5035,8 +4988,7 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virStorageVolDefFree(privvol);
|
virStorageVolDefFree(privvol);
|
||||||
if (obj)
|
virStoragePoolObjUnlock(obj);
|
||||||
virStoragePoolObjUnlock(obj);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5054,14 +5006,8 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
|
if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name)))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (!virStoragePoolObjIsActive(obj)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("storage pool '%s' is not active"), pool->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
privvol = virStorageVolDefParseString(obj->def, xmldesc, 0);
|
privvol = virStorageVolDefParseString(obj->def, xmldesc, 0);
|
||||||
if (privvol == NULL)
|
if (privvol == NULL)
|
||||||
@ -5111,8 +5057,7 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virStorageVolDefFree(privvol);
|
virStorageVolDefFree(privvol);
|
||||||
if (obj)
|
virStoragePoolObjUnlock(obj);
|
||||||
virStoragePoolObjUnlock(obj);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5129,8 +5074,8 @@ testStorageVolDelete(virStorageVolPtr vol,
|
|||||||
|
|
||||||
virCheckFlags(0, -1);
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
if (!(obj = testStoragePoolObjFindByName(privconn, vol->pool)))
|
if (!(obj = testStoragePoolObjFindActiveByName(privconn, vol->pool)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
privvol = virStorageVolDefFindByName(obj, vol->name);
|
privvol = virStorageVolDefFindByName(obj, vol->name);
|
||||||
|
|
||||||
@ -5141,13 +5086,6 @@ testStorageVolDelete(virStorageVolPtr vol,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virStoragePoolObjIsActive(obj)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("storage pool '%s' is not active"), vol->pool);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
obj->def->allocation -= privvol->target.allocation;
|
obj->def->allocation -= privvol->target.allocation;
|
||||||
obj->def->available = (obj->def->capacity - obj->def->allocation);
|
obj->def->available = (obj->def->capacity - obj->def->allocation);
|
||||||
|
|
||||||
@ -5162,8 +5100,7 @@ testStorageVolDelete(virStorageVolPtr vol,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (obj)
|
virStoragePoolObjUnlock(obj);
|
||||||
virStoragePoolObjUnlock(obj);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5192,8 +5129,8 @@ testStorageVolGetInfo(virStorageVolPtr vol,
|
|||||||
virStorageVolDefPtr privvol;
|
virStorageVolDefPtr privvol;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(obj = testStoragePoolObjFindByName(privconn, vol->pool)))
|
if (!(obj = testStoragePoolObjFindActiveByName(privconn, vol->pool)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
privvol = virStorageVolDefFindByName(obj, vol->name);
|
privvol = virStorageVolDefFindByName(obj, vol->name);
|
||||||
|
|
||||||
@ -5204,12 +5141,6 @@ testStorageVolGetInfo(virStorageVolPtr vol,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virStoragePoolObjIsActive(obj)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("storage pool '%s' is not active"), vol->pool);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(info, 0, sizeof(*info));
|
memset(info, 0, sizeof(*info));
|
||||||
info->type = testStorageVolumeTypeForPool(obj->def->type);
|
info->type = testStorageVolumeTypeForPool(obj->def->type);
|
||||||
info->capacity = privvol->target.capacity;
|
info->capacity = privvol->target.capacity;
|
||||||
@ -5217,8 +5148,7 @@ testStorageVolGetInfo(virStorageVolPtr vol,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (obj)
|
virStoragePoolObjUnlock(obj);
|
||||||
virStoragePoolObjUnlock(obj);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5234,8 +5164,8 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol,
|
|||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
if (!(obj = testStoragePoolObjFindByName(privconn, vol->pool)))
|
if (!(obj = testStoragePoolObjFindActiveByName(privconn, vol->pool)))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
privvol = virStorageVolDefFindByName(obj, vol->name);
|
privvol = virStorageVolDefFindByName(obj, vol->name);
|
||||||
|
|
||||||
@ -5246,17 +5176,10 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virStoragePoolObjIsActive(obj)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("storage pool '%s' is not active"), vol->pool);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = virStorageVolDefFormat(obj->def, privvol);
|
ret = virStorageVolDefFormat(obj->def, privvol);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (obj)
|
virStoragePoolObjUnlock(obj);
|
||||||
virStoragePoolObjUnlock(obj);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5269,8 +5192,8 @@ testStorageVolGetPath(virStorageVolPtr vol)
|
|||||||
virStorageVolDefPtr privvol;
|
virStorageVolDefPtr privvol;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
|
|
||||||
if (!(obj = testStoragePoolObjFindByName(privconn, vol->pool)))
|
if (!(obj = testStoragePoolObjFindActiveByName(privconn, vol->pool)))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
privvol = virStorageVolDefFindByName(obj, vol->name);
|
privvol = virStorageVolDefFindByName(obj, vol->name);
|
||||||
|
|
||||||
@ -5281,17 +5204,10 @@ testStorageVolGetPath(virStorageVolPtr vol)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virStoragePoolObjIsActive(obj)) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
_("storage pool '%s' is not active"), vol->pool);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
ignore_value(VIR_STRDUP(ret, privvol->target.path));
|
ignore_value(VIR_STRDUP(ret, privvol->target.path));
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (obj)
|
virStoragePoolObjUnlock(obj);
|
||||||
virStoragePoolObjUnlock(obj);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user