@@ -89,6 +89,13 @@ storagePoolSetInactive(virStoragePoolObjPtr pool)
{
bool ret = false;
pool->active = false;
+ char *stateFile;
+
+ stateFile = virFileBuildPath(driver->stateDir, pool->def->name, ".xml");
+ if (stateFile) {
+ unlink(stateFile);
+ VIR_FREE(stateFile);
+ }
if (pool->configFile == NULL) {
virStoragePoolObjRemove(&driver->pools, pool);
@@ -112,11 +119,6 @@ storagePoolUpdateState(virStoragePoolObjPtr pool)
bool active = false;
virStorageBackendPtr backend;
bool ret = false;
- char *stateFile;
-
- if (!(stateFile = virFileBuildPath(driver->stateDir,
- pool->def->name, ".xml")))
- goto error;
if ((backend = virStorageBackendForType(pool->def->type)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -153,12 +155,8 @@ storagePoolUpdateState(virStoragePoolObjPtr pool)
pool->active = active;
error:
- if (!active) {
+ if (!active)
ret = storagePoolSetInactive(pool);
- if (stateFile)
- unlink(stateFile);
- }
- VIR_FREE(stateFile);
return ret;
}
@@ -210,8 +208,6 @@ storageDriverAutostartPool(virConnectPtr conn,
if (!stateFile ||
virStoragePoolSaveState(stateFile, pool->def) < 0 ||
backend->refreshPool(conn, pool) < 0) {
- if (stateFile)
- unlink(stateFile);
if (backend->stopPool)
backend->stopPool(conn, pool);
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -774,8 +770,6 @@ storagePoolCreateXML(virConnectPtr conn,
virStoragePoolObjClearVols(pool);
if (!stateFile || virStoragePoolSaveState(stateFile, pool->def) < 0 ||
backend->refreshPool(conn, pool) < 0) {
- if (stateFile)
- unlink(stateFile);
if (backend->stopPool)
backend->stopPool(conn, pool);
if (storagePoolSetInactive(pool))
@@ -991,8 +985,6 @@ storagePoolCreate(virStoragePoolPtr obj,
virStoragePoolObjClearVols(pool);
if (!stateFile || virStoragePoolSaveState(stateFile, pool->def) < 0 ||
backend->refreshPool(obj->conn, pool) < 0) {
- if (stateFile)
- unlink(stateFile);
if (backend->stopPool)
backend->stopPool(obj->conn, pool);
@@ -1060,7 +1052,6 @@ storagePoolDestroy(virStoragePoolPtr obj)
virStoragePoolObjPtr pool;
virStorageBackendPtr backend;
virObjectEventPtr event = NULL;
- char *stateFile = NULL;
int ret = -1;
storageDriverLock();
@@ -1094,13 +1085,6 @@ storagePoolDestroy(virStoragePoolPtr obj)
goto cleanup;
}
- if (!(stateFile = virFileBuildPath(driver->stateDir,
- pool->def->name,
- ".xml")))
- goto cleanup;
-
- unlink(stateFile);
- VIR_FREE(stateFile);
if (backend->stopPool &&
backend->stopPool(obj->conn, pool) < 0)