[libvirt] [PATCH 1/6] storage: Break out storageDriverAutostartPool
Ján Tomko
jtomko at redhat.com
Fri Jun 24 13:24:52 UTC 2016
On Wed, Jun 22, 2016 at 08:12:11PM -0400, Cole Robinson wrote:
>For autostarting a single pool. Lets us exit the function early
>which simplifies the control flow, and it matches the pattern
>of storagePoolUpdateAllState
>---
> src/storage/storage_driver.c | 84 +++++++++++++++++++++++---------------------
> 1 file changed, 43 insertions(+), 41 deletions(-)
>
>diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
>index e2d729f..3bdc13f 100644
>--- a/src/storage/storage_driver.c
>+++ b/src/storage/storage_driver.c
>@@ -149,6 +149,48 @@ storagePoolUpdateAllState(void)
> }
>
> static void
>+storageDriverAutostartPool(virConnectPtr conn,
>+ virStoragePoolObjPtr pool)
>+{
>+ virStorageBackendPtr backend;
>+ char *stateFile = NULL;
>+
>+ if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
>+ goto cleanup;
>+
return;
>+ if (virStoragePoolObjIsActive(pool) || !pool->autostart)
>+ goto cleanup;
>+
return;
>+ if (backend->startPool &&
>+ backend->startPool(conn, pool) < 0) {
>+ virReportError(VIR_ERR_INTERNAL_ERROR,
>+ _("Failed to autostart storage pool '%s': %s"),
>+ pool->def->name, virGetLastErrorMessage());
The error message could be shared with an 'error' label.
Jan
>+ goto cleanup;
>+ }
>+
>+ virStoragePoolObjClearVols(pool);
>+ stateFile = virFileBuildPath(driver->stateDir,
>+ pool->def->name, ".xml");
>+ 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,
>+ _("Failed to autostart storage pool '%s': %s"),
>+ pool->def->name, virGetLastErrorMessage());
>+ goto cleanup;
More information about the libvir-list
mailing list