test: Use virStoragePoolObjGetDef accessor

In preparation for privatizing the object, use the accessor.

Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
John Ferlan 2017-05-08 08:21:52 -04:00
parent bb34b61bdf
commit 296d6e2d93

View File

@ -1037,6 +1037,7 @@ testOpenVolumesForPool(const char *file,
virStoragePoolObjPtr obj, virStoragePoolObjPtr obj,
int objidx) int objidx)
{ {
virStoragePoolDefPtr def = virStoragePoolObjGetDef(obj);
char *vol_xpath; char *vol_xpath;
size_t i; size_t i;
int num, ret = -1; int num, ret = -1;
@ -1058,12 +1059,12 @@ testOpenVolumesForPool(const char *file,
if (!node) if (!node)
goto error; goto error;
if (!(volDef = virStorageVolDefParseNode(obj->def, ctxt->doc, node, 0))) if (!(volDef = virStorageVolDefParseNode(def, ctxt->doc, node, 0)))
goto error; goto error;
if (!volDef->target.path) { if (!volDef->target.path) {
if (virAsprintf(&volDef->target.path, "%s/%s", if (virAsprintf(&volDef->target.path, "%s/%s",
obj->def->target.path, volDef->name) < 0) def->target.path, volDef->name) < 0)
goto error; goto error;
} }
@ -1073,8 +1074,8 @@ testOpenVolumesForPool(const char *file,
if (virStoragePoolObjAddVol(obj, volDef) < 0) if (virStoragePoolObjAddVol(obj, volDef) < 0)
goto error; goto error;
obj->def->allocation += volDef->target.allocation; def->allocation += volDef->target.allocation;
obj->def->available = (obj->def->capacity - obj->def->allocation); def->available = (def->capacity - def->allocation);
volDef = NULL; volDef = NULL;
} }
@ -4056,10 +4057,11 @@ static int
testStoragePoolObjSetDefaults(virStoragePoolObjPtr obj) testStoragePoolObjSetDefaults(virStoragePoolObjPtr obj)
{ {
char *configFile; char *configFile;
virStoragePoolDefPtr def = virStoragePoolObjGetDef(obj);
obj->def->capacity = defaultPoolCap; def->capacity = defaultPoolCap;
obj->def->allocation = defaultPoolAlloc; def->allocation = defaultPoolAlloc;
obj->def->available = defaultPoolCap - defaultPoolAlloc; def->available = defaultPoolCap - defaultPoolAlloc;
if (VIR_STRDUP(configFile, "") < 0) if (VIR_STRDUP(configFile, "") < 0)
return -1; return -1;
@ -4156,13 +4158,14 @@ testStoragePoolLookupByUUID(virConnectPtr conn,
{ {
testDriverPtr privconn = conn->privateData; testDriverPtr privconn = conn->privateData;
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
virStoragePoolDefPtr def;
virStoragePoolPtr pool = NULL; virStoragePoolPtr pool = NULL;
if (!(obj = testStoragePoolObjFindByUUID(privconn, uuid))) if (!(obj = testStoragePoolObjFindByUUID(privconn, uuid)))
return NULL; return NULL;
def = virStoragePoolObjGetDef(obj);
pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid, pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
NULL, NULL);
virStoragePoolObjUnlock(obj); virStoragePoolObjUnlock(obj);
return pool; return pool;
@ -4175,13 +4178,14 @@ testStoragePoolLookupByName(virConnectPtr conn,
{ {
testDriverPtr privconn = conn->privateData; testDriverPtr privconn = conn->privateData;
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
virStoragePoolDefPtr def;
virStoragePoolPtr pool = NULL; virStoragePoolPtr pool = NULL;
if (!(obj = testStoragePoolObjFindByName(privconn, name))) if (!(obj = testStoragePoolObjFindByName(privconn, name)))
return NULL; return NULL;
def = virStoragePoolObjGetDef(obj);
pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid, pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
NULL, NULL);
virStoragePoolObjUnlock(obj); virStoragePoolObjUnlock(obj);
return pool; return pool;
@ -4426,38 +4430,40 @@ testStoragePoolCreateXML(virConnectPtr conn,
unsigned int flags) unsigned int flags)
{ {
testDriverPtr privconn = conn->privateData; testDriverPtr privconn = conn->privateData;
virStoragePoolDefPtr def; virStoragePoolDefPtr newDef;
virStoragePoolObjPtr obj = NULL; virStoragePoolObjPtr obj = NULL;
virStoragePoolDefPtr def;
virStoragePoolPtr pool = NULL; virStoragePoolPtr pool = NULL;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
testDriverLock(privconn); testDriverLock(privconn);
if (!(def = virStoragePoolDefParseString(xml))) if (!(newDef = virStoragePoolDefParseString(xml)))
goto cleanup; goto cleanup;
obj = virStoragePoolObjFindByUUID(&privconn->pools, def->uuid); obj = virStoragePoolObjFindByUUID(&privconn->pools, newDef->uuid);
if (!obj) if (!obj)
obj = virStoragePoolObjFindByName(&privconn->pools, def->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, def))) if (!(obj = virStoragePoolObjAssignDef(&privconn->pools, newDef)))
goto cleanup; goto cleanup;
def = NULL; newDef = NULL;
def = virStoragePoolObjGetDef(obj);
if (obj->def->source.adapter.type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { if (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,
obj->def->source.adapter.data.fchost.wwnn, def->source.adapter.data.fchost.wwnn,
obj->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;
@ -4477,14 +4483,14 @@ testStoragePoolCreateXML(virConnectPtr conn,
virStoragePoolObjSetActive(obj, true); virStoragePoolObjSetActive(obj, true);
event = virStoragePoolEventLifecycleNew(obj->def->name, obj->def->uuid, event = virStoragePoolEventLifecycleNew(def->name, def->uuid,
VIR_STORAGE_POOL_EVENT_STARTED, VIR_STORAGE_POOL_EVENT_STARTED,
0); 0);
pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL, NULL); pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
cleanup: cleanup:
virStoragePoolDefFree(def); virStoragePoolDefFree(newDef);
testObjectEventQueue(privconn, event); testObjectEventQueue(privconn, event);
if (obj) if (obj)
virStoragePoolObjUnlock(obj); virStoragePoolObjUnlock(obj);
@ -4499,26 +4505,28 @@ testStoragePoolDefineXML(virConnectPtr conn,
unsigned int flags) unsigned int flags)
{ {
testDriverPtr privconn = conn->privateData; testDriverPtr privconn = conn->privateData;
virStoragePoolDefPtr def; virStoragePoolDefPtr newDef;
virStoragePoolObjPtr obj = NULL; virStoragePoolObjPtr obj = NULL;
virStoragePoolDefPtr def;
virStoragePoolPtr pool = NULL; virStoragePoolPtr pool = NULL;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
virCheckFlags(0, NULL); virCheckFlags(0, NULL);
testDriverLock(privconn); testDriverLock(privconn);
if (!(def = virStoragePoolDefParseString(xml))) if (!(newDef = virStoragePoolDefParseString(xml)))
goto cleanup; goto cleanup;
def->capacity = defaultPoolCap; newDef->capacity = defaultPoolCap;
def->allocation = defaultPoolAlloc; newDef->allocation = defaultPoolAlloc;
def->available = defaultPoolCap - defaultPoolAlloc; newDef->available = defaultPoolCap - defaultPoolAlloc;
if (!(obj = virStoragePoolObjAssignDef(&privconn->pools, def))) if (!(obj = virStoragePoolObjAssignDef(&privconn->pools, newDef)))
goto cleanup; goto cleanup;
def = NULL; newDef = NULL;
def = virStoragePoolObjGetDef(obj);
event = virStoragePoolEventLifecycleNew(obj->def->name, obj->def->uuid, event = virStoragePoolEventLifecycleNew(def->name, def->uuid,
VIR_STORAGE_POOL_EVENT_DEFINED, VIR_STORAGE_POOL_EVENT_DEFINED,
0); 0);
@ -4528,10 +4536,10 @@ testStoragePoolDefineXML(virConnectPtr conn,
goto cleanup; goto cleanup;
} }
pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL, NULL); pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
cleanup: cleanup:
virStoragePoolDefFree(def); virStoragePoolDefFree(newDef);
testObjectEventQueue(privconn, event); testObjectEventQueue(privconn, event);
if (obj) if (obj)
virStoragePoolObjUnlock(obj); virStoragePoolObjUnlock(obj);
@ -4624,24 +4632,25 @@ testStoragePoolDestroy(virStoragePoolPtr pool)
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
virStoragePoolDefPtr def;
int ret = -1; int ret = -1;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name)))
return -1; return -1;
def = virStoragePoolObjGetDef(obj);
virStoragePoolObjSetActive(obj, false); virStoragePoolObjSetActive(obj, false);
if (obj->def->source.adapter.type == if (def->source.adapter.type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST) {
VIR_STORAGE_ADAPTER_TYPE_FC_HOST) {
if (testDestroyVport(privconn, if (testDestroyVport(privconn,
obj->def->source.adapter.data.fchost.wwnn, def->source.adapter.data.fchost.wwnn,
obj->def->source.adapter.data.fchost.wwpn) < 0) def->source.adapter.data.fchost.wwpn) < 0)
goto cleanup; goto cleanup;
} }
event = virStoragePoolEventLifecycleNew(obj->def->name, event = virStoragePoolEventLifecycleNew(def->name,
obj->def->uuid, def->uuid,
VIR_STORAGE_POOL_EVENT_STOPPED, VIR_STORAGE_POOL_EVENT_STOPPED,
0); 0);
@ -4710,18 +4719,20 @@ testStoragePoolGetInfo(virStoragePoolPtr pool,
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
virStoragePoolDefPtr def;
if (!(obj = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
return -1; return -1;
def = virStoragePoolObjGetDef(obj);
memset(info, 0, sizeof(virStoragePoolInfo)); memset(info, 0, sizeof(virStoragePoolInfo));
if (virStoragePoolObjIsActive(obj)) if (virStoragePoolObjIsActive(obj))
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 = obj->def->capacity; info->capacity = def->capacity;
info->allocation = obj->def->allocation; info->allocation = def->allocation;
info->available = obj->def->available; info->available = def->available;
virStoragePoolObjUnlock(obj); virStoragePoolObjUnlock(obj);
return 0; return 0;
@ -4741,7 +4752,7 @@ testStoragePoolGetXMLDesc(virStoragePoolPtr pool,
if (!(obj = testStoragePoolObjFindByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
return NULL; return NULL;
ret = virStoragePoolDefFormat(obj->def); ret = virStoragePoolDefFormat(virStoragePoolObjGetDef(obj));
virStoragePoolObjUnlock(obj); virStoragePoolObjUnlock(obj);
return ret; return ret;
@ -4881,16 +4892,18 @@ testStorageVolLookupByName(virStoragePoolPtr pool,
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
virStoragePoolDefPtr def;
virStorageVolDefPtr privvol; virStorageVolDefPtr privvol;
virStorageVolPtr ret = NULL; virStorageVolPtr ret = NULL;
if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name)))
return NULL; return NULL;
def = virStoragePoolObjGetDef(obj);
if (!(privvol = testStorageVolDefFindByName(obj, name))) if (!(privvol = testStorageVolDefFindByName(obj, name)))
goto cleanup; goto cleanup;
ret = virGetStorageVol(pool->conn, obj->def->name, ret = virGetStorageVol(pool->conn, def->name,
privvol->name, privvol->key, privvol->name, privvol->key,
NULL, NULL); NULL, NULL);
@ -4906,6 +4919,7 @@ testStorageVolLookupByKey(virConnectPtr conn,
{ {
testDriverPtr privconn = conn->privateData; testDriverPtr privconn = conn->privateData;
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
virStoragePoolDefPtr def;
size_t i; size_t i;
virStorageVolPtr ret = NULL; virStorageVolPtr ret = NULL;
@ -4913,14 +4927,13 @@ testStorageVolLookupByKey(virConnectPtr conn,
for (i = 0; i < privconn->pools.count; i++) { for (i = 0; i < privconn->pools.count; i++) {
obj = privconn->pools.objs[i]; obj = privconn->pools.objs[i];
virStoragePoolObjLock(obj); virStoragePoolObjLock(obj);
def = virStoragePoolObjGetDef(obj);
if (virStoragePoolObjIsActive(obj)) { if (virStoragePoolObjIsActive(obj)) {
virStorageVolDefPtr privvol = virStorageVolDefFindByKey(obj, key); virStorageVolDefPtr privvol = virStorageVolDefFindByKey(obj, key);
if (privvol) { if (privvol) {
ret = virGetStorageVol(conn, ret = virGetStorageVol(conn, def->name,
obj->def->name, privvol->name, privvol->key,
privvol->name,
privvol->key,
NULL, NULL); NULL, NULL);
virStoragePoolObjUnlock(obj); virStoragePoolObjUnlock(obj);
break; break;
@ -4944,6 +4957,7 @@ testStorageVolLookupByPath(virConnectPtr conn,
{ {
testDriverPtr privconn = conn->privateData; testDriverPtr privconn = conn->privateData;
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
virStoragePoolDefPtr def;
size_t i; size_t i;
virStorageVolPtr ret = NULL; virStorageVolPtr ret = NULL;
@ -4951,14 +4965,13 @@ testStorageVolLookupByPath(virConnectPtr conn,
for (i = 0; i < privconn->pools.count; i++) { for (i = 0; i < privconn->pools.count; i++) {
obj = privconn->pools.objs[i]; obj = privconn->pools.objs[i];
virStoragePoolObjLock(obj); virStoragePoolObjLock(obj);
def = virStoragePoolObjGetDef(obj);
if (virStoragePoolObjIsActive(obj)) { if (virStoragePoolObjIsActive(obj)) {
virStorageVolDefPtr privvol = virStorageVolDefFindByPath(obj, path); virStorageVolDefPtr privvol = virStorageVolDefFindByPath(obj, path);
if (privvol) { if (privvol) {
ret = virGetStorageVol(conn, ret = virGetStorageVol(conn, def->name,
obj->def->name, privvol->name, privvol->key,
privvol->name,
privvol->key,
NULL, NULL); NULL, NULL);
virStoragePoolObjUnlock(obj); virStoragePoolObjUnlock(obj);
break; break;
@ -4983,6 +4996,7 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
virStoragePoolDefPtr def;
virStorageVolDefPtr privvol = NULL; virStorageVolDefPtr privvol = NULL;
virStorageVolPtr ret = NULL; virStorageVolPtr ret = NULL;
@ -4990,8 +5004,9 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name)))
return NULL; return NULL;
def = virStoragePoolObjGetDef(obj);
privvol = virStorageVolDefParseString(obj->def, xmldesc, 0); privvol = virStorageVolDefParseString(def, xmldesc, 0);
if (privvol == NULL) if (privvol == NULL)
goto cleanup; goto cleanup;
@ -5002,8 +5017,8 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
} }
/* Make sure enough space */ /* Make sure enough space */
if ((obj->def->allocation + privvol->target.allocation) > if ((def->allocation + privvol->target.allocation) >
obj->def->capacity) { 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);
@ -5011,17 +5026,17 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
} }
if (virAsprintf(&privvol->target.path, "%s/%s", if (virAsprintf(&privvol->target.path, "%s/%s",
obj->def->target.path, privvol->name) < 0) def->target.path, privvol->name) < 0)
goto cleanup; goto cleanup;
if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 ||
virStoragePoolObjAddVol(obj, privvol) < 0) virStoragePoolObjAddVol(obj, privvol) < 0)
goto cleanup; goto cleanup;
obj->def->allocation += privvol->target.allocation; def->allocation += privvol->target.allocation;
obj->def->available = (obj->def->capacity - obj->def->allocation); def->available = (def->capacity - def->allocation);
ret = virGetStorageVol(pool->conn, obj->def->name, ret = virGetStorageVol(pool->conn, def->name,
privvol->name, privvol->key, privvol->name, privvol->key,
NULL, NULL); NULL, NULL);
privvol = NULL; privvol = NULL;
@ -5041,6 +5056,7 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
{ {
testDriverPtr privconn = pool->conn->privateData; testDriverPtr privconn = pool->conn->privateData;
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
virStoragePoolDefPtr def;
virStorageVolDefPtr privvol = NULL, origvol = NULL; virStorageVolDefPtr privvol = NULL, origvol = NULL;
virStorageVolPtr ret = NULL; virStorageVolPtr ret = NULL;
@ -5048,8 +5064,9 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name))) if (!(obj = testStoragePoolObjFindActiveByName(privconn, pool->name)))
return NULL; return NULL;
def = virStoragePoolObjGetDef(obj);
privvol = virStorageVolDefParseString(obj->def, xmldesc, 0); privvol = virStorageVolDefParseString(def, xmldesc, 0);
if (privvol == NULL) if (privvol == NULL)
goto cleanup; goto cleanup;
@ -5068,27 +5085,26 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
} }
/* Make sure enough space */ /* Make sure enough space */
if ((obj->def->allocation + privvol->target.allocation) > if ((def->allocation + privvol->target.allocation) > 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;
} }
obj->def->available = (obj->def->capacity - obj->def->allocation); def->available = (def->capacity - def->allocation);
if (virAsprintf(&privvol->target.path, "%s/%s", if (virAsprintf(&privvol->target.path, "%s/%s",
obj->def->target.path, privvol->name) < 0) def->target.path, privvol->name) < 0)
goto cleanup; goto cleanup;
if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 ||
virStoragePoolObjAddVol(obj, privvol) < 0) virStoragePoolObjAddVol(obj, privvol) < 0)
goto cleanup; goto cleanup;
obj->def->allocation += privvol->target.allocation; def->allocation += privvol->target.allocation;
obj->def->available = (obj->def->capacity - obj->def->allocation); def->available = (def->capacity - def->allocation);
ret = virGetStorageVol(pool->conn, obj->def->name, ret = virGetStorageVol(pool->conn, def->name,
privvol->name, privvol->key, privvol->name, privvol->key,
NULL, NULL); NULL, NULL);
privvol = NULL; privvol = NULL;
@ -5106,6 +5122,7 @@ testStorageVolDelete(virStorageVolPtr vol,
{ {
testDriverPtr privconn = vol->conn->privateData; testDriverPtr privconn = vol->conn->privateData;
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
virStoragePoolDefPtr def;
virStorageVolDefPtr privvol; virStorageVolDefPtr privvol;
int ret = -1; int ret = -1;
@ -5113,12 +5130,13 @@ testStorageVolDelete(virStorageVolPtr vol,
if (!(obj = testStoragePoolObjFindActiveByName(privconn, vol->pool))) if (!(obj = testStoragePoolObjFindActiveByName(privconn, vol->pool)))
return -1; return -1;
def = virStoragePoolObjGetDef(obj);
if (!(privvol = testStorageVolDefFindByName(obj, vol->name))) if (!(privvol = testStorageVolDefFindByName(obj, vol->name)))
goto cleanup; goto cleanup;
obj->def->allocation -= privvol->target.allocation; def->allocation -= privvol->target.allocation;
obj->def->available = (obj->def->capacity - obj->def->allocation); def->available = (def->capacity - def->allocation);
virStoragePoolObjRemoveVol(obj, privvol); virStoragePoolObjRemoveVol(obj, privvol);
@ -5151,17 +5169,19 @@ testStorageVolGetInfo(virStorageVolPtr vol,
{ {
testDriverPtr privconn = vol->conn->privateData; testDriverPtr privconn = vol->conn->privateData;
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
virStoragePoolDefPtr def;
virStorageVolDefPtr privvol; virStorageVolDefPtr privvol;
int ret = -1; int ret = -1;
if (!(obj = testStoragePoolObjFindActiveByName(privconn, vol->pool))) if (!(obj = testStoragePoolObjFindActiveByName(privconn, vol->pool)))
return -1; return -1;
def = virStoragePoolObjGetDef(obj);
if (!(privvol = testStorageVolDefFindByName(obj, vol->name))) if (!(privvol = testStorageVolDefFindByName(obj, vol->name)))
goto cleanup; goto cleanup;
memset(info, 0, sizeof(*info)); memset(info, 0, sizeof(*info));
info->type = testStorageVolumeTypeForPool(obj->def->type); info->type = testStorageVolumeTypeForPool(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;
@ -5189,7 +5209,7 @@ testStorageVolGetXMLDesc(virStorageVolPtr vol,
if (!(privvol = testStorageVolDefFindByName(obj, vol->name))) if (!(privvol = testStorageVolDefFindByName(obj, vol->name)))
goto cleanup; goto cleanup;
ret = virStorageVolDefFormat(obj->def, privvol); ret = virStorageVolDefFormat(virStoragePoolObjGetDef(obj), privvol);
cleanup: cleanup:
virStoragePoolObjUnlock(obj); virStoragePoolObjUnlock(obj);