In preparation for privatizing the object, use the accessors.
Perform some minor code cleanup along the w/r/t spacing, line wraps, etc.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/storage/storage_driver.c | 426 ++++++++++++++++++++++++-------------------
1 file changed, 242 insertions(+), 184 deletions(-)
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index fc393dd..7d491bf 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -90,14 +90,14 @@ static void
virStoragePoolUpdateInactive(virStoragePoolObjPtr *objptr)
{
virStoragePoolObjPtr obj = *objptr;
+ virStoragePoolDefPtr newDef = virStoragePoolObjGetNewDef(obj);
+ char *configFile = virStoragePoolObjGetConfigFile(obj);
- if (obj->configFile == NULL) {
+ if (!configFile) {
virStoragePoolObjRemove(&driver->pools, obj);
*objptr = NULL;
- } else if (obj->newDef) {
- virStoragePoolDefFree(obj->def);
- obj->def = obj->newDef;
- obj->newDef = NULL;
+ } else if (newDef) {
+ virStoragePoolObjStealNewDef(obj);
}
}
@@ -105,17 +105,17 @@ virStoragePoolUpdateInactive(virStoragePoolObjPtr *objptr)
static void
storagePoolUpdateState(virStoragePoolObjPtr obj)
{
+ virStoragePoolDefPtr def = virStoragePoolObjGetDef(obj);
bool active = false;
virStorageBackendPtr backend;
char *stateFile;
- if (!(stateFile = virFileBuildPath(driver->stateDir,
- obj->def->name, ".xml")))
+ if (!(stateFile = virFileBuildPath(driver->stateDir, def->name,
".xml")))
goto cleanup;
- if ((backend = virStorageBackendForType(obj->def->type)) == NULL) {
+ if ((backend = virStorageBackendForType(def->type)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Missing backend %d"), obj->def->type);
+ _("Missing backend %d"), def->type);
goto cleanup;
}
@@ -125,7 +125,7 @@ storagePoolUpdateState(virStoragePoolObjPtr obj)
backend->checkPool(obj, &active) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to initialize storage pool '%s':
%s"),
- obj->def->name, virGetLastErrorMessage());
+ def->name, virGetLastErrorMessage());
active = false;
}
@@ -140,14 +140,14 @@ storagePoolUpdateState(virStoragePoolObjPtr obj)
backend->stopPool(NULL, obj);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to restart storage pool '%s':
%s"),
- obj->def->name, virGetLastErrorMessage());
+ def->name, virGetLastErrorMessage());
active = false;
}
}
- obj->active = active;
+ virStoragePoolObjSetActive(obj, active);
- if (!obj->active)
+ if (!virStoragePoolObjIsActive(obj))
virStoragePoolUpdateInactive(&obj);
cleanup:
@@ -187,22 +187,23 @@ storageDriverAutostart(void)
for (i = 0; i < driver->pools.count; i++) {
virStoragePoolObjPtr obj = driver->pools.objs[i];
+ virStoragePoolDefPtr def = virStoragePoolObjGetDef(obj);
virStorageBackendPtr backend;
bool started = false;
virStoragePoolObjLock(obj);
- if ((backend = virStorageBackendForType(obj->def->type)) == NULL) {
+ if ((backend = virStorageBackendForType(def->type)) == NULL) {
virStoragePoolObjUnlock(obj);
continue;
}
- if (obj->autostart &&
+ if (virStoragePoolObjGetAutostart(obj) &&
!virStoragePoolObjIsActive(obj)) {
if (backend->startPool &&
backend->startPool(conn, obj) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to autostart storage pool '%s':
%s"),
- obj->def->name, virGetLastErrorMessage());
+ def->name, virGetLastErrorMessage());
virStoragePoolObjUnlock(obj);
continue;
}
@@ -213,10 +214,9 @@ storageDriverAutostart(void)
char *stateFile;
virStoragePoolObjClearVols(obj);
- stateFile = virFileBuildPath(driver->stateDir,
- obj->def->name, ".xml");
+ stateFile = virFileBuildPath(driver->stateDir, def->name,
".xml");
if (!stateFile ||
- virStoragePoolSaveState(stateFile, obj->def) < 0 ||
+ virStoragePoolSaveState(stateFile, def) < 0 ||
backend->refreshPool(conn, obj) < 0) {
if (stateFile)
unlink(stateFile);
@@ -224,9 +224,9 @@ storageDriverAutostart(void)
backend->stopPool(conn, obj);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to autostart storage pool '%s':
%s"),
- obj->def->name, virGetLastErrorMessage());
+ def->name, virGetLastErrorMessage());
} else {
- obj->active = true;
+ virStoragePoolObjSetActive(obj, true);
}
VIR_FREE(stateFile);
}
@@ -443,6 +443,7 @@ storagePoolLookupByUUID(virConnectPtr conn,
const unsigned char *uuid)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
virStoragePoolPtr pool = NULL;
storageDriverLock();
@@ -450,11 +451,12 @@ storagePoolLookupByUUID(virConnectPtr conn,
storageDriverUnlock();
if (!obj)
return NULL;
+ def = virStoragePoolObjGetDef(obj);
- if (virStoragePoolLookupByUUIDEnsureACL(conn, obj->def) < 0)
+ if (virStoragePoolLookupByUUIDEnsureACL(conn, def) < 0)
goto cleanup;
- pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,
NULL);
+ pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
cleanup:
virStoragePoolObjUnlock(obj);
@@ -466,15 +468,17 @@ storagePoolLookupByName(virConnectPtr conn,
const char *name)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
virStoragePoolPtr pool = NULL;
if (!(obj = storagePoolObjFindByName(name)))
return NULL;
+ def = virStoragePoolObjGetDef(obj);
- if (virStoragePoolLookupByNameEnsureACL(conn, obj->def) < 0)
+ if (virStoragePoolLookupByNameEnsureACL(conn, def) < 0)
goto cleanup;
- pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,
NULL);
+ pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
cleanup:
virStoragePoolObjUnlock(obj);
@@ -485,16 +489,17 @@ static virStoragePoolPtr
storagePoolLookupByVolume(virStorageVolPtr vol)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
virStoragePoolPtr pool = NULL;
if (!(obj = storagePoolObjFindByName(vol->pool)))
return NULL;
+ def = virStoragePoolObjGetDef(obj);
- if (virStoragePoolLookupByVolumeEnsureACL(vol->conn, obj->def) < 0)
+ if (virStoragePoolLookupByVolumeEnsureACL(vol->conn, def) < 0)
goto cleanup;
- pool = virGetStoragePool(vol->conn, obj->def->name, obj->def->uuid,
- NULL, NULL);
+ pool = virGetStoragePool(vol->conn, def->name, def->uuid, NULL, NULL);
cleanup:
virStoragePoolObjUnlock(obj);
@@ -615,12 +620,14 @@ static int
storagePoolIsActive(virStoragePoolPtr pool)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
int ret = -1;
if (!(obj = virStoragePoolObjFromStoragePool(pool)))
return -1;
+ def = virStoragePoolObjGetDef(obj);
- if (virStoragePoolIsActiveEnsureACL(pool->conn, obj->def) < 0)
+ if (virStoragePoolIsActiveEnsureACL(pool->conn, def) < 0)
goto cleanup;
ret = virStoragePoolObjIsActive(obj);
@@ -635,15 +642,17 @@ static int
storagePoolIsPersistent(virStoragePoolPtr pool)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
int ret = -1;
if (!(obj = virStoragePoolObjFromStoragePool(pool)))
return -1;
+ def = virStoragePoolObjGetDef(obj);
- if (virStoragePoolIsPersistentEnsureACL(pool->conn, obj->def) < 0)
+ if (virStoragePoolIsPersistentEnsureACL(pool->conn, def) < 0)
goto cleanup;
- ret = obj->configFile ? 1 : 0;
+ ret = virStoragePoolObjGetConfigFile(obj) ? 1 : 0;
cleanup:
virStoragePoolObjUnlock(obj);
@@ -658,6 +667,7 @@ storagePoolCreateXML(virConnectPtr conn,
{
virStoragePoolDefPtr def;
virStoragePoolObjPtr obj = NULL;
+ virStoragePoolDefPtr objdef;
virStoragePoolPtr pool = NULL;
virStorageBackendPtr backend;
virObjectEventPtr event = NULL;
@@ -690,6 +700,7 @@ storagePoolCreateXML(virConnectPtr conn,
if (!(obj = virStoragePoolObjAssignDef(&driver->pools, def)))
goto cleanup;
def = NULL;
+ objdef = virStoragePoolObjGetDef(obj);
if (backend->buildPool) {
if (flags & VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE)
@@ -714,11 +725,10 @@ storagePoolCreateXML(virConnectPtr conn,
goto cleanup;
}
- stateFile = virFileBuildPath(driver->stateDir,
- obj->def->name, ".xml");
+ stateFile = virFileBuildPath(driver->stateDir, objdef->name,
".xml");
virStoragePoolObjClearVols(obj);
- if (!stateFile || virStoragePoolSaveState(stateFile, obj->def) < 0 ||
+ if (!stateFile || virStoragePoolSaveState(stateFile, objdef) < 0 ||
backend->refreshPool(conn, obj) < 0) {
if (stateFile)
unlink(stateFile);
@@ -729,15 +739,15 @@ storagePoolCreateXML(virConnectPtr conn,
goto cleanup;
}
- event = virStoragePoolEventLifecycleNew(obj->def->name,
- obj->def->uuid,
+ event = virStoragePoolEventLifecycleNew(objdef->name,
+ objdef->uuid,
VIR_STORAGE_POOL_EVENT_STARTED,
0);
- VIR_INFO("Creating storage pool '%s'", obj->def->name);
- obj->active = true;
+ VIR_INFO("Creating storage pool '%s'", objdef->name);
+ virStoragePoolObjSetActive(obj, true);
- pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,
NULL);
+ pool = virGetStoragePool(conn, objdef->name, objdef->uuid, NULL, NULL);
cleanup:
VIR_FREE(stateFile);
@@ -757,6 +767,7 @@ storagePoolDefineXML(virConnectPtr conn,
{
virStoragePoolDefPtr def;
virStoragePoolObjPtr obj = NULL;
+ virStoragePoolDefPtr objdef;
virStoragePoolPtr pool = NULL;
virObjectEventPtr event = NULL;
@@ -783,22 +794,21 @@ storagePoolDefineXML(virConnectPtr conn,
if (!(obj = virStoragePoolObjAssignDef(&driver->pools, def)))
goto cleanup;
+ def = NULL;
+ objdef = virStoragePoolObjGetDef(obj);
- if (virStoragePoolObjSaveDef(driver, obj, def) < 0) {
+ if (virStoragePoolObjSaveDef(driver, obj, objdef) < 0) {
virStoragePoolObjRemove(&driver->pools, obj);
- def = NULL;
obj = NULL;
goto cleanup;
}
- event = virStoragePoolEventLifecycleNew(def->name, def->uuid,
+ event = virStoragePoolEventLifecycleNew(objdef->name, objdef->uuid,
VIR_STORAGE_POOL_EVENT_DEFINED,
0);
- def = NULL;
-
- VIR_INFO("Defining storage pool '%s'", obj->def->name);
- pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid, NULL,
NULL);
+ VIR_INFO("Defining storage pool '%s'", objdef->name);
+ pool = virGetStoragePool(conn, objdef->name, objdef->uuid, NULL, NULL);
cleanup:
if (event)
@@ -814,39 +824,41 @@ static int
storagePoolUndefine(virStoragePoolPtr pool)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
virObjectEventPtr event = NULL;
int ret = -1;
storageDriverLock();
if (!(obj = storagePoolObjFindByUUID(pool->uuid, pool->name)))
goto cleanup;
+ def = virStoragePoolObjGetDef(obj);
- if (virStoragePoolUndefineEnsureACL(pool->conn, obj->def) < 0)
+ if (virStoragePoolUndefineEnsureACL(pool->conn, def) < 0)
goto cleanup;
if (virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is still active"),
- obj->def->name);
+ def->name);
goto cleanup;
}
- if (obj->asyncjobs > 0) {
+ if (virStoragePoolObjGetAsyncjobs(obj) > 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("pool '%s' has asynchronous jobs running."),
- obj->def->name);
+ def->name);
goto cleanup;
}
if (virStoragePoolObjDeleteDef(obj) < 0)
goto cleanup;
- event = virStoragePoolEventLifecycleNew(obj->def->name,
- obj->def->uuid,
+ event = virStoragePoolEventLifecycleNew(def->name,
+ def->uuid,
VIR_STORAGE_POOL_EVENT_UNDEFINED,
0);
- VIR_INFO("Undefining storage pool '%s'", obj->def->name);
+ VIR_INFO("Undefining storage pool '%s'", def->name);
virStoragePoolObjRemove(&driver->pools, obj);
obj = NULL;
ret = 0;
@@ -865,6 +877,7 @@ storagePoolCreate(virStoragePoolPtr pool,
unsigned int flags)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
virStorageBackendPtr backend;
virObjectEventPtr event = NULL;
int ret = -1;
@@ -880,17 +893,18 @@ storagePoolCreate(virStoragePoolPtr pool,
if (!(obj = virStoragePoolObjFromStoragePool(pool)))
return -1;
+ def = virStoragePoolObjGetDef(obj);
- if (virStoragePoolCreateEnsureACL(pool->conn, obj->def) < 0)
+ if (virStoragePoolCreateEnsureACL(pool->conn, def) < 0)
goto cleanup;
- if ((backend = virStorageBackendForType(obj->def->type)) == NULL)
+ if ((backend = virStorageBackendForType(def->type)) == NULL)
goto cleanup;
if (virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is already active"),
- obj->def->name);
+ def->name);
goto cleanup;
}
@@ -907,16 +921,15 @@ storagePoolCreate(virStoragePoolPtr pool,
}
}
- VIR_INFO("Starting up storage pool '%s'", obj->def->name);
+ VIR_INFO("Starting up storage pool '%s'", def->name);
if (backend->startPool &&
backend->startPool(pool->conn, obj) < 0)
goto cleanup;
- stateFile = virFileBuildPath(driver->stateDir,
- obj->def->name, ".xml");
+ stateFile = virFileBuildPath(driver->stateDir, def->name, ".xml");
virStoragePoolObjClearVols(obj);
- if (!stateFile || virStoragePoolSaveState(stateFile, obj->def) < 0 ||
+ if (!stateFile || virStoragePoolSaveState(stateFile, def) < 0 ||
backend->refreshPool(pool->conn, obj) < 0) {
if (stateFile)
unlink(stateFile);
@@ -925,12 +938,12 @@ storagePoolCreate(virStoragePoolPtr pool,
goto cleanup;
}
- event = virStoragePoolEventLifecycleNew(obj->def->name,
- obj->def->uuid,
+ event = virStoragePoolEventLifecycleNew(def->name,
+ def->uuid,
VIR_STORAGE_POOL_EVENT_STARTED,
0);
- obj->active = true;
+ virStoragePoolObjSetActive(obj, true);
ret = 0;
cleanup:
@@ -947,22 +960,24 @@ storagePoolBuild(virStoragePoolPtr pool,
unsigned int flags)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
virStorageBackendPtr backend;
int ret = -1;
if (!(obj = virStoragePoolObjFromStoragePool(pool)))
return -1;
+ def = virStoragePoolObjGetDef(obj);
- if (virStoragePoolBuildEnsureACL(pool->conn, obj->def) < 0)
+ if (virStoragePoolBuildEnsureACL(pool->conn, def) < 0)
goto cleanup;
- if ((backend = virStorageBackendForType(obj->def->type)) == NULL)
+ if ((backend = virStorageBackendForType(def->type)) == NULL)
goto cleanup;
if (virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is already active"),
- obj->def->name);
+ def->name);
goto cleanup;
}
@@ -981,6 +996,7 @@ static int
storagePoolDestroy(virStoragePoolPtr pool)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
virStorageBackendPtr backend;
virObjectEventPtr event = NULL;
char *stateFile = NULL;
@@ -989,31 +1005,30 @@ storagePoolDestroy(virStoragePoolPtr pool)
storageDriverLock();
if (!(obj = storagePoolObjFindByUUID(pool->uuid, pool->name)))
goto cleanup;
+ def = virStoragePoolObjGetDef(obj);
- if (virStoragePoolDestroyEnsureACL(pool->conn, obj->def) < 0)
+ if (virStoragePoolDestroyEnsureACL(pool->conn, def) < 0)
goto cleanup;
- if ((backend = virStorageBackendForType(obj->def->type)) == NULL)
+ if ((backend = virStorageBackendForType(def->type)) == NULL)
goto cleanup;
- VIR_INFO("Destroying storage pool '%s'", obj->def->name);
+ VIR_INFO("Destroying storage pool '%s'", def->name);
if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID,
- _("storage pool '%s' is not active"),
obj->def->name);
+ _("storage pool '%s' is not active"),
def->name);
goto cleanup;
}
- if (obj->asyncjobs > 0) {
+ if (virStoragePoolObjGetAsyncjobs(obj) > 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("pool '%s' has asynchronous jobs running."),
- obj->def->name);
+ def->name);
goto cleanup;
}
- if (!(stateFile = virFileBuildPath(driver->stateDir,
- obj->def->name,
- ".xml")))
+ if (!(stateFile = virFileBuildPath(driver->stateDir, def->name,
".xml")))
goto cleanup;
unlink(stateFile);
@@ -1025,12 +1040,12 @@ storagePoolDestroy(virStoragePoolPtr pool)
virStoragePoolObjClearVols(obj);
- event = virStoragePoolEventLifecycleNew(obj->def->name,
- obj->def->uuid,
+ event = virStoragePoolEventLifecycleNew(def->name,
+ def->uuid,
VIR_STORAGE_POOL_EVENT_STOPPED,
0);
- obj->active = false;
+ virStoragePoolObjSetActive(obj, false);
virStoragePoolUpdateInactive(&obj);
@@ -1050,38 +1065,38 @@ storagePoolDelete(virStoragePoolPtr pool,
unsigned int flags)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
virStorageBackendPtr backend;
char *stateFile = NULL;
int ret = -1;
if (!(obj = virStoragePoolObjFromStoragePool(pool)))
return -1;
+ def = virStoragePoolObjGetDef(obj);
- if (virStoragePoolDeleteEnsureACL(pool->conn, obj->def) < 0)
+ if (virStoragePoolDeleteEnsureACL(pool->conn, def) < 0)
goto cleanup;
- if ((backend = virStorageBackendForType(obj->def->type)) == NULL)
+ if ((backend = virStorageBackendForType(def->type)) == NULL)
goto cleanup;
- VIR_INFO("Deleting storage pool '%s'", obj->def->name);
+ VIR_INFO("Deleting storage pool '%s'", def->name);
if (virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is still active"),
- obj->def->name);
+ def->name);
goto cleanup;
}
- if (obj->asyncjobs > 0) {
+ if (virStoragePoolObjGetAsyncjobs(obj) > 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("pool '%s' has asynchronous jobs running."),
- obj->def->name);
+ def->name);
goto cleanup;
}
- if (!(stateFile = virFileBuildPath(driver->stateDir,
- obj->def->name,
- ".xml")))
+ if (!(stateFile = virFileBuildPath(driver->stateDir, def->name,
".xml")))
goto cleanup;
unlink(stateFile);
@@ -1108,6 +1123,7 @@ storagePoolRefresh(virStoragePoolPtr pool,
unsigned int flags)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
virStorageBackendPtr backend;
int ret = -1;
virObjectEventPtr event = NULL;
@@ -1117,23 +1133,24 @@ storagePoolRefresh(virStoragePoolPtr pool,
storageDriverLock();
if (!(obj = storagePoolObjFindByUUID(pool->uuid, pool->name)))
goto cleanup;
+ def = virStoragePoolObjGetDef(obj);
- if (virStoragePoolRefreshEnsureACL(pool->conn, obj->def) < 0)
+ if (virStoragePoolRefreshEnsureACL(pool->conn, def) < 0)
goto cleanup;
- if ((backend = virStorageBackendForType(obj->def->type)) == NULL)
+ if ((backend = virStorageBackendForType(def->type)) == NULL)
goto cleanup;
if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID,
- _("storage pool '%s' is not active"),
obj->def->name);
+ _("storage pool '%s' is not active"),
def->name);
goto cleanup;
}
- if (obj->asyncjobs > 0) {
+ if (virStoragePoolObjGetAsyncjobs(obj) > 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("pool '%s' has asynchronous jobs running."),
- obj->def->name);
+ def->name);
goto cleanup;
}
@@ -1142,19 +1159,19 @@ storagePoolRefresh(virStoragePoolPtr pool,
if (backend->stopPool)
backend->stopPool(pool->conn, obj);
- event = virStoragePoolEventLifecycleNew(obj->def->name,
- obj->def->uuid,
+ event = virStoragePoolEventLifecycleNew(def->name,
+ def->uuid,
VIR_STORAGE_POOL_EVENT_STOPPED,
0);
- obj->active = false;
+ virStoragePoolObjSetActive(obj, false);
virStoragePoolUpdateInactive(&obj);
goto cleanup;
}
- event = virStoragePoolEventRefreshNew(obj->def->name,
- obj->def->uuid);
+ event = virStoragePoolEventRefreshNew(def->name,
+ def->uuid);
ret = 0;
cleanup:
@@ -1172,25 +1189,27 @@ storagePoolGetInfo(virStoragePoolPtr pool,
virStoragePoolInfoPtr info)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
int ret = -1;
if (!(obj = virStoragePoolObjFromStoragePool(pool)))
return -1;
+ def = virStoragePoolObjGetDef(obj);
- if (virStoragePoolGetInfoEnsureACL(pool->conn, obj->def) < 0)
+ if (virStoragePoolGetInfoEnsureACL(pool->conn, def) < 0)
goto cleanup;
- if (virStorageBackendForType(obj->def->type) == NULL)
+ if (virStorageBackendForType(def->type) == NULL)
goto cleanup;
memset(info, 0, sizeof(virStoragePoolInfo));
- if (obj->active)
+ if (virStoragePoolObjIsActive(obj))
info->state = VIR_STORAGE_POOL_RUNNING;
else
info->state = VIR_STORAGE_POOL_INACTIVE;
- info->capacity = obj->def->capacity;
- info->allocation = obj->def->allocation;
- info->available = obj->def->available;
+ info->capacity = def->capacity;
+ info->allocation = def->allocation;
+ info->available = def->available;
ret = 0;
cleanup:
@@ -1203,6 +1222,8 @@ storagePoolGetXMLDesc(virStoragePoolPtr pool,
unsigned int flags)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr objdef;
+ virStoragePoolDefPtr newDef;
virStoragePoolDefPtr def;
char *ret = NULL;
@@ -1210,14 +1231,16 @@ storagePoolGetXMLDesc(virStoragePoolPtr pool,
if (!(obj = virStoragePoolObjFromStoragePool(pool)))
return NULL;
+ objdef = virStoragePoolObjGetDef(obj);
+ newDef = virStoragePoolObjGetNewDef(obj);
- if (virStoragePoolGetXMLDescEnsureACL(pool->conn, obj->def) < 0)
+ if (virStoragePoolGetXMLDescEnsureACL(pool->conn, objdef) < 0)
goto cleanup;
- if ((flags & VIR_STORAGE_XML_INACTIVE) && obj->newDef)
- def = obj->newDef;
+ if ((flags & VIR_STORAGE_XML_INACTIVE) && newDef)
+ def = newDef;
else
- def = obj->def;
+ def = objdef;
ret = virStoragePoolDefFormat(def);
@@ -1236,7 +1259,8 @@ storagePoolGetAutostart(virStoragePoolPtr pool,
if (!(obj = virStoragePoolObjFromStoragePool(pool)))
return -1;
- if (virStoragePoolGetAutostartEnsureACL(pool->conn, obj->def) < 0)
+ if (virStoragePoolGetAutostartEnsureACL(pool->conn,
+ virStoragePoolObjGetDef(obj)) < 0)
goto cleanup;
*autostart = virStoragePoolObjGetAutostart(obj);
@@ -1259,7 +1283,8 @@ storagePoolSetAutostart(virStoragePoolPtr pool,
if (!(obj = storagePoolObjFindByUUID(pool->uuid, pool->name)))
goto cleanup;
- if (virStoragePoolSetAutostartEnsureACL(pool->conn, obj->def) < 0)
+ if (virStoragePoolSetAutostartEnsureACL(pool->conn,
+ virStoragePoolObjGetDef(obj)) < 0)
goto cleanup;
if (virStoragePoolObjSetAutostart(obj, driver->autostartDir, autostart) < 0)
@@ -1279,17 +1304,19 @@ static int
storagePoolNumOfVolumes(virStoragePoolPtr pool)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
int ret = -1;
if (!(obj = virStoragePoolObjFromStoragePool(pool)))
return -1;
+ def = virStoragePoolObjGetDef(obj);
- if (virStoragePoolNumOfVolumesEnsureACL(pool->conn, obj->def) < 0)
+ if (virStoragePoolNumOfVolumesEnsureACL(pool->conn, def) < 0)
goto cleanup;
if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID,
- _("storage pool '%s' is not active"),
obj->def->name);
+ _("storage pool '%s' is not active"),
def->name);
goto cleanup;
}
@@ -1308,17 +1335,19 @@ storagePoolListVolumes(virStoragePoolPtr pool,
int maxnames)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
int n = -1;
if (!(obj = virStoragePoolObjFromStoragePool(pool)))
return -1;
+ def = virStoragePoolObjGetDef(obj);
- if (virStoragePoolListVolumesEnsureACL(pool->conn, obj->def) < 0)
+ if (virStoragePoolListVolumesEnsureACL(pool->conn, def) < 0)
goto cleanup;
if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID,
- _("storage pool '%s' is not active"),
obj->def->name);
+ _("storage pool '%s' is not active"),
def->name);
goto cleanup;
}
@@ -1337,19 +1366,21 @@ storagePoolListAllVolumes(virStoragePoolPtr pool,
unsigned int flags)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
int ret = -1;
virCheckFlags(0, -1);
if (!(obj = virStoragePoolObjFromStoragePool(pool)))
return -1;
+ def = virStoragePoolObjGetDef(obj);
- if (virStoragePoolListAllVolumesEnsureACL(pool->conn, obj->def) < 0)
+ if (virStoragePoolListAllVolumesEnsureACL(pool->conn, def) < 0)
goto cleanup;
if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID,
- _("storage pool '%s' is not active"),
obj->def->name);
+ _("storage pool '%s' is not active"),
def->name);
goto cleanup;
}
@@ -1368,15 +1399,17 @@ storageVolLookupByName(virStoragePoolPtr pool,
const char *name)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
virStorageVolDefPtr voldef;
virStorageVolPtr vol = NULL;
if (!(obj = virStoragePoolObjFromStoragePool(pool)))
return NULL;
+ def = virStoragePoolObjGetDef(obj);
if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID,
- _("storage pool '%s' is not active"),
obj->def->name);
+ _("storage pool '%s' is not active"),
def->name);
goto cleanup;
}
@@ -1389,10 +1422,10 @@ storageVolLookupByName(virStoragePoolPtr pool,
goto cleanup;
}
- if (virStorageVolLookupByNameEnsureACL(pool->conn, obj->def, voldef) < 0)
+ if (virStorageVolLookupByNameEnsureACL(pool->conn, def, voldef) < 0)
goto cleanup;
- vol = virGetStorageVol(pool->conn, obj->def->name, voldef->name,
+ vol = virGetStorageVol(pool->conn, def->name, voldef->name,
voldef->key, NULL, NULL);
cleanup:
@@ -1410,26 +1443,26 @@ storageVolLookupByKey(virConnectPtr conn,
storageDriverLock();
for (i = 0; i < driver->pools.count && !vol; i++) {
- virStoragePoolObjLock(driver->pools.objs[i]);
- if (virStoragePoolObjIsActive(driver->pools.objs[i])) {
- virStorageVolDefPtr voldef =
- virStorageVolDefFindByKey(driver->pools.objs[i], key);
+ virStoragePoolObjPtr obj = driver->pools.objs[i];
+ virStoragePoolDefPtr def;
+
+ virStoragePoolObjLock(obj);
+ def = virStoragePoolObjGetDef(obj);
+ if (virStoragePoolObjIsActive(obj)) {
+ virStorageVolDefPtr voldef = virStorageVolDefFindByKey(obj, key);
if (voldef) {
- virStoragePoolDefPtr def = driver->pools.objs[i]->def;
if (virStorageVolLookupByKeyEnsureACL(conn, def, voldef) < 0) {
- virStoragePoolObjUnlock(driver->pools.objs[i]);
+ virStoragePoolObjUnlock(obj);
goto cleanup;
}
- vol = virGetStorageVol(conn,
- def->name,
- voldef->name,
- voldef->key,
+ vol = virGetStorageVol(conn, def->name,
+ voldef->name, voldef->key,
NULL, NULL);
}
}
- virStoragePoolObjUnlock(driver->pools.objs[i]);
+ virStoragePoolObjUnlock(obj);
}
if (!vol)
@@ -1456,17 +1489,19 @@ storageVolLookupByPath(virConnectPtr conn,
storageDriverLock();
for (i = 0; i < driver->pools.count && !vol; i++) {
virStoragePoolObjPtr obj = driver->pools.objs[i];
+ virStoragePoolDefPtr def;
virStorageVolDefPtr voldef;
char *stable_path = NULL;
virStoragePoolObjLock(obj);
+ def = virStoragePoolObjGetDef(obj);
if (!virStoragePoolObjIsActive(obj)) {
virStoragePoolObjUnlock(obj);
continue;
}
- switch ((virStoragePoolType) obj->def->type) {
+ switch ((virStoragePoolType) def->type) {
case VIR_STORAGE_POOL_DIR:
case VIR_STORAGE_POOL_FS:
case VIR_STORAGE_POOL_NETFS:
@@ -1484,7 +1519,7 @@ storageVolLookupByPath(virConnectPtr conn,
* getting the stable path for some of the pools.
*/
VIR_WARN("Failed to get stable path for pool
'%s'",
- obj->def->name);
+ def->name);
virStoragePoolObjUnlock(obj);
continue;
}
@@ -1506,12 +1541,12 @@ storageVolLookupByPath(virConnectPtr conn,
VIR_FREE(stable_path);
if (voldef) {
- if (virStorageVolLookupByPathEnsureACL(conn, obj->def, voldef) < 0) {
+ if (virStorageVolLookupByPathEnsureACL(conn, def, voldef) < 0) {
virStoragePoolObjUnlock(obj);
goto cleanup;
}
- vol = virGetStorageVol(conn, obj->def->name,
+ vol = virGetStorageVol(conn, def->name,
voldef->name, voldef->key,
NULL, NULL);
}
@@ -1551,18 +1586,18 @@ storagePoolLookupByTargetPath(virConnectPtr conn,
storageDriverLock();
for (i = 0; i < driver->pools.count && !pool; i++) {
virStoragePoolObjPtr obj = driver->pools.objs[i];
+ virStoragePoolDefPtr def;
virStoragePoolObjLock(obj);
+ def = virStoragePoolObjGetDef(obj);
if (!virStoragePoolObjIsActive(obj)) {
virStoragePoolObjUnlock(obj);
continue;
}
- if (STREQ(path, obj->def->target.path)) {
- pool = virGetStoragePool(conn, obj->def->name, obj->def->uuid,
- NULL, NULL);
- }
+ if (STREQ(path, def->target.path))
+ pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
virStoragePoolObjUnlock(obj);
}
@@ -1587,6 +1622,7 @@ storageVolDeleteInternal(virStorageVolPtr vol,
unsigned int flags,
bool updateMeta)
{
+ virStoragePoolDefPtr def = virStoragePoolObjGetDef(obj);
int ret = -1;
if (!backend->deleteVol) {
@@ -1604,9 +1640,9 @@ storageVolDeleteInternal(virStorageVolPtr vol,
* Ignore the disk backend since it updates the pool values.
*/
if (updateMeta) {
- if (obj->def->type != VIR_STORAGE_POOL_DISK) {
- obj->def->allocation -= voldef->target.allocation;
- obj->def->available += voldef->target.allocation;
+ if (def->type != VIR_STORAGE_POOL_DISK) {
+ def->allocation -= voldef->target.allocation;
+ def->available += voldef->target.allocation;
}
}
@@ -1624,14 +1660,16 @@ virStorageVolDefFromVol(virStorageVolPtr vol,
virStorageBackendPtr *backend)
{
virStorageVolDefPtr voldef = NULL;
+ virStoragePoolDefPtr def;
if (!(*obj = storagePoolObjFindByName(vol->pool)))
return NULL;
+ def = virStoragePoolObjGetDef(*obj);
if (!virStoragePoolObjIsActive(*obj)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"),
- (*obj)->def->name);
+ def->name);
goto error;
}
@@ -1643,7 +1681,7 @@ virStorageVolDefFromVol(virStorageVolPtr vol,
}
if (backend) {
- if (!(*backend = virStorageBackendForType((*obj)->def->type)))
+ if (!(*backend = virStorageBackendForType(def->type)))
goto error;
}
@@ -1669,7 +1707,8 @@ storageVolDelete(virStorageVolPtr vol,
if (!(voldef = virStorageVolDefFromVol(vol, &obj, &backend)))
return -1;
- if (virStorageVolDeleteEnsureACL(vol->conn, obj->def, voldef) < 0)
+ if (virStorageVolDeleteEnsureACL(vol->conn, virStoragePoolObjGetDef(obj),
+ voldef) < 0)
goto cleanup;
if (voldef->in_use) {
@@ -1703,6 +1742,7 @@ storageVolCreateXML(virStoragePoolPtr pool,
unsigned int flags)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
virStorageBackendPtr backend;
virStorageVolDefPtr voldef = NULL;
virStorageVolPtr vol = NULL, volobj = NULL;
@@ -1711,17 +1751,18 @@ storageVolCreateXML(virStoragePoolPtr pool,
if (!(obj = virStoragePoolObjFromStoragePool(pool)))
return NULL;
+ def = virStoragePoolObjGetDef(obj);
if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID,
- _("storage pool '%s' is not active"),
obj->def->name);
+ _("storage pool '%s' is not active"),
def->name);
goto cleanup;
}
- if ((backend = virStorageBackendForType(obj->def->type)) == NULL)
+ if ((backend = virStorageBackendForType(def->type)) == NULL)
goto cleanup;
- voldef = virStorageVolDefParseString(obj->def, xmldesc,
+ voldef = virStorageVolDefParseString(def, xmldesc,
VIR_VOL_XML_PARSE_OPT_CAPACITY);
if (voldef == NULL)
goto cleanup;
@@ -1733,7 +1774,7 @@ storageVolCreateXML(virStoragePoolPtr pool,
goto cleanup;
}
- if (virStorageVolCreateXMLEnsureACL(pool->conn, obj->def, voldef) < 0)
+ if (virStorageVolCreateXMLEnsureACL(pool->conn, def, voldef) < 0)
goto cleanup;
if (virStorageVolDefFindByName(obj, voldef->name)) {
@@ -1755,7 +1796,7 @@ storageVolCreateXML(virStoragePoolPtr pool,
if (backend->createVol(pool->conn, obj, voldef) < 0)
goto cleanup;
- if (!(volobj = virGetStorageVol(pool->conn, obj->def->name,
voldef->name,
+ if (!(volobj = virGetStorageVol(pool->conn, def->name, voldef->name,
voldef->key, NULL, NULL)))
goto cleanup;
@@ -1779,7 +1820,7 @@ storageVolCreateXML(virStoragePoolPtr pool,
memcpy(buildvoldef, voldef, sizeof(*voldef));
/* Drop the pool lock during volume allocation */
- obj->asyncjobs++;
+ virStoragePoolObjIncrAsyncjobs(obj);
voldef->building = true;
virStoragePoolObjUnlock(obj);
@@ -1792,7 +1833,7 @@ storageVolCreateXML(virStoragePoolPtr pool,
storageDriverUnlock();
voldef->building = false;
- obj->asyncjobs--;
+ virStoragePoolObjDecrAsyncjobs(obj);
if (buildret < 0) {
/* buildVol handles deleting volume on failure */
@@ -1814,13 +1855,13 @@ storageVolCreateXML(virStoragePoolPtr pool,
/* Update pool metadata ignoring the disk backend since
* it updates the pool values.
*/
- if (obj->def->type != VIR_STORAGE_POOL_DISK) {
- obj->def->allocation += voldef->target.allocation;
- obj->def->available -= voldef->target.allocation;
+ if (def->type != VIR_STORAGE_POOL_DISK) {
+ def->allocation += voldef->target.allocation;
+ def->available -= voldef->target.allocation;
}
VIR_INFO("Creating volume '%s' in storage pool '%s'",
- volobj->name, obj->def->name);
+ volobj->name, def->name);
vol = volobj;
volobj = NULL;
voldef = NULL;
@@ -1840,6 +1881,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
unsigned int flags)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
virStoragePoolObjPtr objsrc = NULL;
virStorageBackendPtr backend;
virStorageVolDefPtr voldefsrc = NULL;
@@ -1869,6 +1911,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
uuidstr, pool->name);
goto cleanup;
}
+ def = virStoragePoolObjGetDef(obj);
if (STRNEQ(pool->name, volsrc->pool) && !objsrc) {
virReportError(VIR_ERR_NO_STORAGE_POOL,
@@ -1879,18 +1922,19 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
if (!virStoragePoolObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_INVALID,
- _("storage pool '%s' is not active"),
obj->def->name);
+ _("storage pool '%s' is not active"),
def->name);
goto cleanup;
}
if (objsrc && !virStoragePoolObjIsActive(objsrc)) {
+ virStoragePoolDefPtr objsrcdef = virStoragePoolObjGetDef(objsrc);
virReportError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"),
- objsrc->def->name);
+ objsrcdef->name);
goto cleanup;
}
- if ((backend = virStorageBackendForType(obj->def->type)) == NULL)
+ if ((backend = virStorageBackendForType(def->type)) == NULL)
goto cleanup;
voldefsrc = virStorageVolDefFindByName(objsrc ?
@@ -1902,12 +1946,12 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
goto cleanup;
}
- voldef = virStorageVolDefParseString(obj->def, xmldesc,
+ voldef = virStorageVolDefParseString(def, xmldesc,
VIR_VOL_XML_PARSE_NO_CAPACITY);
if (voldef == NULL)
goto cleanup;
- if (virStorageVolCreateXMLFromEnsureACL(pool->conn, obj->def, voldef) < 0)
+ if (virStorageVolCreateXMLFromEnsureACL(pool->conn, def, voldef) < 0)
goto cleanup;
if (virStorageVolDefFindByName(obj, voldef->name)) {
@@ -1963,7 +2007,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
memcpy(shadowvol, voldef, sizeof(*voldef));
- if (!(volobj = virGetStorageVol(pool->conn, obj->def->name,
voldef->name,
+ if (!(volobj = virGetStorageVol(pool->conn, def->name, voldef->name,
voldef->key, NULL, NULL)))
goto cleanup;
@@ -1972,13 +2016,13 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
goto cleanup;
/* Drop the pool lock during volume allocation */
- obj->asyncjobs++;
+ virStoragePoolObjIncrAsyncjobs(obj);
voldef->building = true;
voldefsrc->in_use++;
virStoragePoolObjUnlock(obj);
if (objsrc) {
- objsrc->asyncjobs++;
+ virStoragePoolObjIncrAsyncjobs(objsrc);
virStoragePoolObjUnlock(objsrc);
}
@@ -1992,10 +2036,10 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
voldefsrc->in_use--;
voldef->building = false;
- obj->asyncjobs--;
+ virStoragePoolObjDecrAsyncjobs(obj);
if (objsrc) {
- objsrc->asyncjobs--;
+ virStoragePoolObjDecrAsyncjobs(objsrc);
virStoragePoolObjUnlock(objsrc);
objsrc = NULL;
}
@@ -2011,13 +2055,13 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
/* Updating pool metadata ignoring the disk backend since
* it updates the pool values
*/
- if (obj->def->type != VIR_STORAGE_POOL_DISK) {
- obj->def->allocation += voldef->target.allocation;
- obj->def->available -= voldef->target.allocation;
+ if (def->type != VIR_STORAGE_POOL_DISK) {
+ def->allocation += voldef->target.allocation;
+ def->available -= voldef->target.allocation;
}
VIR_INFO("Creating volume '%s' in storage pool '%s'",
- volobj->name, obj->def->name);
+ volobj->name, def->name);
vol = volobj;
volobj = NULL;
voldef = NULL;
@@ -2051,7 +2095,8 @@ storageVolDownload(virStorageVolPtr vol,
if (!(voldef = virStorageVolDefFromVol(vol, &obj, &backend)))
return -1;
- if (virStorageVolDownloadEnsureACL(vol->conn, obj->def, voldef) < 0)
+ if (virStorageVolDownloadEnsureACL(vol->conn, virStoragePoolObjGetDef(obj),
+ voldef) < 0)
goto cleanup;
if (voldef->building) {
@@ -2145,6 +2190,7 @@ virStorageVolPoolRefreshThread(void *opaque)
virStorageVolStreamInfoPtr cbdata = opaque;
virStoragePoolObjPtr obj = NULL;
+ virStoragePoolDefPtr def;
virStorageBackendPtr backend;
virObjectEventPtr event = NULL;
@@ -2156,16 +2202,16 @@ virStorageVolPoolRefreshThread(void *opaque)
if (!(obj = virStoragePoolObjFindByName(&driver->pools,
cbdata->pool_name)))
goto cleanup;
+ def = virStoragePoolObjGetDef(obj);
- if (!(backend = virStorageBackendForType(obj->def->type)))
+ if (!(backend = virStorageBackendForType(def->type)))
goto cleanup;
virStoragePoolObjClearVols(obj);
if (backend->refreshPool(NULL, obj) < 0)
VIR_DEBUG("Failed to refresh storage pool");
- event = virStoragePoolEventRefreshNew(obj->def->name,
- obj->def->uuid);
+ event = virStoragePoolEventRefreshNew(def->name, def->uuid);
cleanup:
if (event)
@@ -2210,6 +2256,7 @@ storageVolUpload(virStorageVolPtr vol,
{
virStorageBackendPtr backend;
virStoragePoolObjPtr obj = NULL;
+ virStoragePoolDefPtr def;
virStorageVolDefPtr voldef = NULL;
virStorageVolStreamInfoPtr cbdata = NULL;
int ret = -1;
@@ -2218,8 +2265,9 @@ storageVolUpload(virStorageVolPtr vol,
if (!(voldef = virStorageVolDefFromVol(vol, &obj, &backend)))
return -1;
+ def = virStoragePoolObjGetDef(obj);
- if (virStorageVolUploadEnsureACL(vol->conn, obj->def, voldef) < 0)
+ if (virStorageVolUploadEnsureACL(vol->conn, def, voldef) < 0)
goto cleanup;
if (voldef->in_use) {
@@ -2249,7 +2297,7 @@ storageVolUpload(virStorageVolPtr vol,
* routine in order to call the refresh API.
*/
if (VIR_ALLOC(cbdata) < 0 ||
- VIR_STRDUP(cbdata->pool_name, obj->def->name) < 0)
+ VIR_STRDUP(cbdata->pool_name, def->name) < 0)
goto cleanup;
if (voldef->type == VIR_STORAGE_VOL_PLOOP &&
VIR_STRDUP(cbdata->vol_path, voldef->target.path) < 0)
@@ -2282,6 +2330,7 @@ storageVolResize(virStorageVolPtr vol,
{
virStorageBackendPtr backend;
virStoragePoolObjPtr obj = NULL;
+ virStoragePoolDefPtr def;
virStorageVolDefPtr voldef = NULL;
unsigned long long abs_capacity, delta = 0;
int ret = -1;
@@ -2292,8 +2341,9 @@ storageVolResize(virStorageVolPtr vol,
if (!(voldef = virStorageVolDefFromVol(vol, &obj, &backend)))
return -1;
+ def = virStoragePoolObjGetDef(obj);
- if (virStorageVolResizeEnsureACL(vol->conn, obj->def, voldef) < 0)
+ if (virStorageVolResizeEnsureACL(vol->conn, def, voldef) < 0)
goto cleanup;
if (voldef->in_use) {
@@ -2338,7 +2388,7 @@ storageVolResize(virStorageVolPtr vol,
if (flags & VIR_STORAGE_VOL_RESIZE_ALLOCATE)
delta = abs_capacity - voldef->target.allocation;
- if (delta > obj->def->available) {
+ if (delta > def->available) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Not enough space left in storage pool"));
goto cleanup;
@@ -2361,8 +2411,8 @@ storageVolResize(virStorageVolPtr vol,
*/
if (flags & VIR_STORAGE_VOL_RESIZE_ALLOCATE) {
voldef->target.allocation = abs_capacity;
- obj->def->allocation += delta;
- obj->def->available -= delta;
+ def->allocation += delta;
+ def->available -= delta;
}
ret = 0;
@@ -2396,7 +2446,9 @@ storageVolWipePattern(virStorageVolPtr vol,
if (!(voldef = virStorageVolDefFromVol(vol, &obj, &backend)))
return -1;
- if (virStorageVolWipePatternEnsureACL(vol->conn, obj->def, voldef) < 0)
+ if (virStorageVolWipePatternEnsureACL(vol->conn,
+ virStoragePoolObjGetDef(obj),
+ voldef) < 0)
goto cleanup;
if (voldef->in_use) {
@@ -2457,7 +2509,9 @@ storageVolGetInfoFlags(virStorageVolPtr vol,
if (!(voldef = virStorageVolDefFromVol(vol, &obj, &backend)))
return -1;
- if (virStorageVolGetInfoFlagsEnsureACL(vol->conn, obj->def, voldef) < 0)
+ if (virStorageVolGetInfoFlagsEnsureACL(vol->conn,
+ virStoragePoolObjGetDef(obj),
+ voldef) < 0)
goto cleanup;
if (backend->refreshVol &&
@@ -2492,6 +2546,7 @@ storageVolGetXMLDesc(virStorageVolPtr vol,
unsigned int flags)
{
virStoragePoolObjPtr obj;
+ virStoragePoolDefPtr def;
virStorageBackendPtr backend;
virStorageVolDefPtr voldef;
char *ret = NULL;
@@ -2500,15 +2555,16 @@ storageVolGetXMLDesc(virStorageVolPtr vol,
if (!(voldef = virStorageVolDefFromVol(vol, &obj, &backend)))
return NULL;
+ def = virStoragePoolObjGetDef(obj);
- if (virStorageVolGetXMLDescEnsureACL(vol->conn, obj->def, voldef) < 0)
+ if (virStorageVolGetXMLDescEnsureACL(vol->conn, def, voldef) < 0)
goto cleanup;
if (backend->refreshVol &&
backend->refreshVol(vol->conn, obj, voldef) < 0)
goto cleanup;
- ret = virStorageVolDefFormat(obj->def, voldef);
+ ret = virStorageVolDefFormat(def, voldef);
cleanup:
virStoragePoolObjUnlock(obj);
@@ -2526,7 +2582,8 @@ storageVolGetPath(virStorageVolPtr vol)
if (!(voldef = virStorageVolDefFromVol(vol, &obj, NULL)))
return NULL;
- if (virStorageVolGetPathEnsureACL(vol->conn, obj->def, voldef) < 0)
+ if (virStorageVolGetPathEnsureACL(vol->conn, virStoragePoolObjGetDef(obj),
+ voldef) < 0)
goto cleanup;
ignore_value(VIR_STRDUP(ret, voldef->target.path));
@@ -3484,9 +3541,10 @@ virStoragePoolObjBuildTempFilePath(virStoragePoolObjPtr obj,
virStorageVolDefPtr voldef)
{
+ virStoragePoolDefPtr def = virStoragePoolObjGetDef(obj);
char *tmp = NULL;
ignore_value(virAsprintf(&tmp, "%s/%s.%s.secret.XXXXXX",
- driver->stateDir, obj->def->name,
voldef->name));
+ driver->stateDir, def->name, voldef->name));
return tmp;
}
--
2.9.3