]> xenbits.xensource.com Git - libvirt.git/commitdiff
storagePoolRefreshFailCleanup: Clear volumes on failed refresh
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 28 Feb 2019 17:07:02 +0000 (18:07 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Sat, 16 Mar 2019 06:50:51 +0000 (07:50 +0100)
If pool refresh failed, then the internal table of volumes is
probably left in inconsistent or incomplete state anyways. Clear
it out then. This has an advantage that we can move the
virStoragePoolObjClearVols() from those very few backends that
do call it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/storage/storage_backend_gluster.c
src/storage/storage_backend_logical.c
src/storage/storage_backend_rbd.c
src/storage/storage_driver.c
src/storage/storage_util.c

index 819993439ad93b8d2a6b4f367cccb0aaf9452f61..5955d834d9384ff86ef1bf20e9bf331647f5f145 100644 (file)
@@ -402,8 +402,6 @@ virStorageBackendGlusterRefreshPool(virStoragePoolObjPtr pool)
     if (dir)
         glfs_closedir(dir);
     virStorageBackendGlusterClose(state);
-    if (ret < 0)
-        virStoragePoolObjClearVols(pool);
     return ret;
 }
 
index 77e4dfb8b183d1e4fe0b0e0be4df1f2c45394a56..83b5f27151d0be02a59c8ecff47a8078e20c4f90 100644 (file)
@@ -760,14 +760,13 @@ virStorageBackendLogicalRefreshPool(virStoragePoolObjPtr pool)
         2
     };
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
-    int ret = -1;
     VIR_AUTOPTR(virCommand) cmd = NULL;
 
     virWaitForDevices();
 
     /* Get list of all logical volumes */
     if (virStorageBackendLogicalFindLVs(pool, NULL) < 0)
-        goto cleanup;
+        return -1;
 
     cmd = virCommandNewArgList(VGS,
                                "--separator", ":",
@@ -788,14 +787,9 @@ virStorageBackendLogicalRefreshPool(virStoragePoolObjPtr pool)
                            pool,
                            "vgs",
                            NULL) < 0)
-        goto cleanup;
-
-    ret = 0;
+        return -1;
 
- cleanup:
-    if (ret < 0)
-        virStoragePoolObjClearVols(pool);
-    return ret;
+    return 0;
 }
 
 /*
index 2b7af1db2390372caef42b70df844147e847bbd8..3eae780c440021ef2a640925ae04fc1f6414a1ff 100644 (file)
@@ -648,10 +648,8 @@ virStorageBackendRBDRefreshPool(virStoragePoolObjPtr pool)
             goto cleanup;
         }
 
-        if (virStoragePoolObjAddVol(pool, vol) < 0) {
-            virStoragePoolObjClearVols(pool);
+        if (virStoragePoolObjAddVol(pool, vol) < 0)
             goto cleanup;
-        }
         vol = NULL;
     }
 
index 04fb1ffe8e4f8c45e331c7cd04d2bc91b18b3c98..95561a0578c7207d8c6ff6f8181f0c382fea7ccf 100644 (file)
@@ -82,6 +82,8 @@ storagePoolRefreshFailCleanup(virStorageBackendPtr backend,
 {
     virErrorPtr orig_err = virSaveLastError();
 
+    virStoragePoolObjClearVols(obj);
+
     if (stateFile)
         unlink(stateFile);
     if (backend->stopPool)
index 7a879b0f46fffba41f9ef419118b45e7f481f799..62f857f9eab9a06f8321bae4832c9a8f42a0df78 100644 (file)
@@ -3620,8 +3620,6 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
     ret = 0;
  cleanup:
     VIR_DIR_CLOSE(dir);
-    if (ret < 0)
-        virStoragePoolObjClearVols(pool);
     return ret;
 }