render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From 19778995ed94278db561db198a402d232027aeb8 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <19778995ed94278db561db198a402d232027aeb8@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Fri, 28 Feb 2020 10:24:38 +0100
a41c76
Subject: [PATCH] virStorageSourceNewFromBacking: Also transfer the format
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
When we create the new virStorageSource from the definitions stored in
a41c76
the parent we should also use the 'backingStoreRawFormat' field to
a41c76
populate the format.
a41c76
a41c76
Callers which use virStorageSourceNewFromBacking are also fixed to stop
a41c76
setting the format manually.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit 264b79c63a518df8ce32a78dda51ae554cd2d5f2)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1798148
a41c76
Message-Id: <c9015f51f31c9a088983562298aaf61b1c43d927.1582881363.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/storage/storage_util.c | 5 +----
a41c76
 src/util/virstoragefile.c  | 3 +--
a41c76
 2 files changed, 2 insertions(+), 6 deletions(-)
a41c76
a41c76
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
a41c76
index c562cf313f..f3e899d0ca 100644
a41c76
--- a/src/storage/storage_util.c
a41c76
+++ b/src/storage/storage_util.c
a41c76
@@ -3316,7 +3316,6 @@ static int
a41c76
 storageBackendProbeTarget(virStorageSourcePtr target,
a41c76
                           virStorageEncryptionPtr *encryption)
a41c76
 {
a41c76
-    int backingStoreFormat;
a41c76
     int rc;
a41c76
     struct stat sb;
a41c76
     g_autoptr(virStorageSource) meta = NULL;
a41c76
@@ -3347,15 +3346,13 @@ storageBackendProbeTarget(virStorageSourcePtr target,
a41c76
     if (!(meta = virStorageFileGetMetadataFromFD(target->path,
a41c76
                                                  fd,
a41c76
                                                  VIR_STORAGE_FILE_AUTO,
a41c76
-                                                 &backingStoreFormat)))
a41c76
+                                                 NULL)))
a41c76
         return -1;
a41c76
 
a41c76
     if (meta->backingStoreRaw) {
a41c76
         if (virStorageSourceNewFromBacking(meta, &target->backingStore) < 0)
a41c76
             return -1;
a41c76
 
a41c76
-        target->backingStore->format = backingStoreFormat;
a41c76
-
a41c76
         /* XXX: Remote storage doesn't play nicely with volumes backed by
a41c76
          * remote storage. To avoid trouble, just fake the backing store is RAW
a41c76
          * and put the string from the metadata as the path of the target. */
a41c76
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
a41c76
index d594ee3695..d80780e291 100644
a41c76
--- a/src/util/virstoragefile.c
a41c76
+++ b/src/util/virstoragefile.c
a41c76
@@ -3824,6 +3824,7 @@ virStorageSourceNewFromBacking(virStorageSourcePtr parent,
a41c76
                                            backing)) < 0)
a41c76
         return rc;
a41c76
 
a41c76
+    (*backing)->format = parent->backingStoreRawFormat;
a41c76
     (*backing)->readonly = true;
a41c76
     return rc;
a41c76
 }
a41c76
@@ -5028,8 +5029,6 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
a41c76
         if (rv == 1)
a41c76
             return 0;
a41c76
 
a41c76
-        backingStore->format = src->backingStoreRawFormat;
a41c76
-
a41c76
         if (backingStore->format == VIR_STORAGE_FILE_AUTO) {
a41c76
             /* Assuming the backing store to be raw can lead to failures. We do
a41c76
              * it only when we must not report an error to prevent losing VMs.
a41c76
-- 
a41c76
2.25.1
a41c76