]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: driver: Remove unavailable transient pools after restart
authorPeter Krempa <pkrempa@redhat.com>
Thu, 30 Mar 2017 11:47:45 +0000 (13:47 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 3 Apr 2017 06:42:09 +0000 (08:42 +0200)
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

src/storage/storage_driver.c

index 618b640a2e54d1d0c72079a837768deaac09d17b..fea769887272a8ebbc64cc744276383aa2380528 100644 (file)
@@ -105,31 +105,28 @@ virStoragePoolUpdateInactive(virStoragePoolObjPtr *poolptr)
 static void
 storagePoolUpdateState(virStoragePoolObjPtr pool)
 {
-    bool active;
+    bool active = false;
     virStorageBackendPtr backend;
-    int ret = -1;
     char *stateFile;
 
     if (!(stateFile = virFileBuildPath(driver->stateDir,
                                        pool->def->name, ".xml")))
-        goto error;
+        goto cleanup;
 
     if ((backend = virStorageBackendForType(pool->def->type)) == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Missing backend %d"), pool->def->type);
-        goto error;
+        goto cleanup;
     }
 
     /* Backends which do not support 'checkPool' are considered
-     * inactive by default.
-     */
-    active = false;
+     * inactive by default. */
     if (backend->checkPool &&
         backend->checkPool(pool, &active) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Failed to initialize storage pool '%s': %s"),
                        pool->def->name, virGetLastErrorMessage());
-        goto error;
+        active = false;
     }
 
     /* We can pass NULL as connection, most backends do not use
@@ -144,17 +141,18 @@ storagePoolUpdateState(virStoragePoolObjPtr pool)
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Failed to restart storage pool '%s': %s"),
                            pool->def->name, virGetLastErrorMessage());
-            goto error;
+            active = false;
         }
     }
 
     pool->active = active;
-    ret = 0;
- error:
-    if (ret < 0) {
-        if (stateFile)
-            unlink(stateFile);
-    }
+
+    if (!pool->active)
+        virStoragePoolUpdateInactive(&pool);
+
+ cleanup:
+    if (!active && stateFile)
+        ignore_value(unlink(stateFile));
     VIR_FREE(stateFile);
 
     return;