]> xenbits.xensource.com Git - libvirt.git/commitdiff
storageVolWipePattern: Don't take shortcut to refreshPool()
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 28 Feb 2019 16:35:14 +0000 (17:35 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 18 Mar 2019 12:20:36 +0000 (13:20 +0100)
In d16f803d780 we've tried to solve an issue that after wiping an
image its format might have changed (e.g. from qcow2 to raw) but
libvirt wasn't probing the image format. We fixed this by calling
virStorageBackendRefreshVolTargetUpdate() which is what
refreshPool() would end up calling. But this shortcut is not good
enough because the function is called only for local types of
volumes (like dir, fs, netfs). But now that more backends support
volume wiping we have to call the function with more caution.

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

index 95561a0578c7207d8c6ff6f8181f0c382fea7ccf..496d51b1e071cdb6d7db7d5c5e2bb298e0141e22 100644 (file)
@@ -2572,11 +2572,16 @@ storageVolWipePattern(virStorageVolPtr vol,
     if (rc < 0)
         goto cleanup;
 
-    /* Instead of using the refreshVol, since much changes on the target
-     * volume, let's update using the same function as refreshPool would
-     * use when it discovers a volume. The only failure to capture is -1,
-     * we can ignore -2. */
-    if (virStorageBackendRefreshVolTargetUpdate(voldef) == -1)
+    /* For local volumes, Instead of using the refreshVol, since
+     * much changes on the target volume, let's update using the
+     * same function as refreshPool would use when it discovers a
+     * volume. The only failure to capture is -1, we can ignore
+     * -2. */
+    if ((backend->type == VIR_STORAGE_POOL_DIR ||
+         backend->type == VIR_STORAGE_POOL_FS ||
+         backend->type == VIR_STORAGE_POOL_NETFS ||
+         backend->type == VIR_STORAGE_POOL_VSTORAGE) &&
+        virStorageBackendRefreshVolTargetUpdate(voldef) == -1)
         goto cleanup;
 
     ret = 0;