@@ -102,12 +102,16 @@ storagePoolSetInactive(virStoragePoolObjPtr pool)
return ret;
}
-static void
+/*
+ * Returns true if pool was removed from driver->pools, via
+ * storagePoolSetInactive
+ */
+static bool
storagePoolUpdateState(virStoragePoolObjPtr pool)
{
- bool active;
+ bool active = false;
virStorageBackendPtr backend;
- int ret = -1;
+ bool ret = false;
char *stateFile;
if (!(stateFile = virFileBuildPath(driver->stateDir,
@@ -123,7 +127,6 @@ storagePoolUpdateState(virStoragePoolObjPtr pool)
/* Backends which do not support 'checkPool' are considered
* inactive by default.
*/
- active = false;
if (backend->checkPool &&
backend->checkPool(pool, &active) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -149,15 +152,15 @@ storagePoolUpdateState(virStoragePoolObjPtr pool)
}
pool->active = active;
- ret = 0;
error:
- if (ret < 0) {
+ if (!active) {
+ ret = storagePoolSetInactive(pool);
if (stateFile)
unlink(stateFile);
}
VIR_FREE(stateFile);
- return;
+ return ret;
}
static void
@@ -169,7 +172,13 @@ storagePoolUpdateAllState(void)
virStoragePoolObjPtr pool = driver->pools.objs[i];
virStoragePoolObjLock(pool);
- storagePoolUpdateState(pool);
+ if (storagePoolUpdateState(pool)) {
+ /* The transient pool was removed from the list, while we
+ are iterating over the list. Adjust the counter backwards
+ to match */
+ --i;
+ continue;
+ }
virStoragePoolObjUnlock(pool);
}
}