Re: [PATCH 1/6] storage: Break out storageDriverAutostartPool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]