]> xenbits.xensource.com Git - libvirt.git/commitdiff
virStorageSourceNewFromBacking: Also transfer the format
authorPeter Krempa <pkrempa@redhat.com>
Fri, 21 Feb 2020 11:51:35 +0000 (12:51 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 24 Feb 2020 14:12:32 +0000 (15:12 +0100)
When we create the new virStorageSource from the definitions stored in
the parent we should also use the 'backingStoreRawFormat' field to
populate the format.

Callers which use virStorageSourceNewFromBacking are also fixed to stop
setting the format manually.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/storage/storage_util.c
src/util/virstoragefile.c

index 8199c7a2af414941ee1634bae90c73770b8b97b1..f71abbd72956a8e49bacb5db217f24987989db57 100644 (file)
@@ -3329,7 +3329,6 @@ static int
 storageBackendProbeTarget(virStorageSourcePtr target,
                           virStorageEncryptionPtr *encryption)
 {
-    int backingStoreFormat;
     int rc;
     struct stat sb;
     g_autoptr(virStorageSource) meta = NULL;
@@ -3360,15 +3359,13 @@ storageBackendProbeTarget(virStorageSourcePtr target,
     if (!(meta = virStorageFileGetMetadataFromFD(target->path,
                                                  fd,
                                                  VIR_STORAGE_FILE_AUTO,
-                                                 &backingStoreFormat)))
+                                                 NULL)))
         return -1;
 
     if (meta->backingStoreRaw) {
         if (virStorageSourceNewFromBacking(meta, &target->backingStore) < 0)
             return -1;
 
-        target->backingStore->format = backingStoreFormat;
-
         /* XXX: Remote storage doesn't play nicely with volumes backed by
          * remote storage. To avoid trouble, just fake the backing store is RAW
          * and put the string from the metadata as the path of the target. */
index 2d8fe59c2531542df7867b12c2fde58f8ac140a0..6fddc0610e5e862ecceb3c3e9d0b4c8f227b5d63 100644 (file)
@@ -3824,6 +3824,7 @@ virStorageSourceNewFromBacking(virStorageSourcePtr parent,
                                            backing)) < 0)
         return rc;
 
+    (*backing)->format = parent->backingStoreRawFormat;
     (*backing)->readonly = true;
     return rc;
 }
@@ -5028,8 +5029,6 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
         if (rv == 1)
             return 0;
 
-        backingStore->format = src->backingStoreRawFormat;
-
         if (backingStore->format == VIR_STORAGE_FILE_AUTO) {
             /* Assuming the backing store to be raw can lead to failures. We do
              * it only when we must not report an error to prevent losing VMs.