mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
storage: driver: Remove unavailable transient pools after restart
If a transient storage pool is deemed inactive after libvirtd restart it
would not be deleted from the list. Reuse virStoragePoolUpdateInactive
along with a refactor necessary to properly update the state.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1242801
(cherry picked from commit f3a8e80c13
)
This commit is contained in:
parent
87ed28f6a5
commit
2d5c306616
@ -104,31 +104,28 @@ virStoragePoolUpdateInactive(virStoragePoolObjPtr *poolptr)
|
|||||||
static void
|
static void
|
||||||
storagePoolUpdateState(virStoragePoolObjPtr pool)
|
storagePoolUpdateState(virStoragePoolObjPtr pool)
|
||||||
{
|
{
|
||||||
bool active;
|
bool active = false;
|
||||||
virStorageBackendPtr backend;
|
virStorageBackendPtr backend;
|
||||||
int ret = -1;
|
|
||||||
char *stateFile;
|
char *stateFile;
|
||||||
|
|
||||||
if (!(stateFile = virFileBuildPath(driver->stateDir,
|
if (!(stateFile = virFileBuildPath(driver->stateDir,
|
||||||
pool->def->name, ".xml")))
|
pool->def->name, ".xml")))
|
||||||
goto error;
|
goto cleanup;
|
||||||
|
|
||||||
if ((backend = virStorageBackendForType(pool->def->type)) == NULL) {
|
if ((backend = virStorageBackendForType(pool->def->type)) == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Missing backend %d"), pool->def->type);
|
_("Missing backend %d"), pool->def->type);
|
||||||
goto error;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Backends which do not support 'checkPool' are considered
|
/* Backends which do not support 'checkPool' are considered
|
||||||
* inactive by default.
|
* inactive by default. */
|
||||||
*/
|
|
||||||
active = false;
|
|
||||||
if (backend->checkPool &&
|
if (backend->checkPool &&
|
||||||
backend->checkPool(pool, &active) < 0) {
|
backend->checkPool(pool, &active) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to initialize storage pool '%s': %s"),
|
_("Failed to initialize storage pool '%s': %s"),
|
||||||
pool->def->name, virGetLastErrorMessage());
|
pool->def->name, virGetLastErrorMessage());
|
||||||
goto error;
|
active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We can pass NULL as connection, most backends do not use
|
/* We can pass NULL as connection, most backends do not use
|
||||||
@ -143,17 +140,18 @@ storagePoolUpdateState(virStoragePoolObjPtr pool)
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to restart storage pool '%s': %s"),
|
_("Failed to restart storage pool '%s': %s"),
|
||||||
pool->def->name, virGetLastErrorMessage());
|
pool->def->name, virGetLastErrorMessage());
|
||||||
goto error;
|
active = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pool->active = active;
|
pool->active = active;
|
||||||
ret = 0;
|
|
||||||
error:
|
if (!pool->active)
|
||||||
if (ret < 0) {
|
virStoragePoolUpdateInactive(&pool);
|
||||||
if (stateFile)
|
|
||||||
unlink(stateFile);
|
cleanup:
|
||||||
}
|
if (!active && stateFile)
|
||||||
|
ignore_value(unlink(stateFile));
|
||||||
VIR_FREE(stateFile);
|
VIR_FREE(stateFile);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user