render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
fbe740
From a3a9d320ac8cde96c976378b92dc4fcf553d9287 Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <a3a9d320ac8cde96c976378b92dc4fcf553d9287@dist-git>
fbe740
From: Peter Krempa <pkrempa@redhat.com>
fbe740
Date: Fri, 3 Apr 2020 14:32:55 +0200
fbe740
Subject: [PATCH] qemuDomainSnapshotDiskPrepareOne: Fix logic of relative
fbe740
 backing store update
fbe740
MIME-Version: 1.0
fbe740
Content-Type: text/plain; charset=UTF-8
fbe740
Content-Transfer-Encoding: 8bit
fbe740
fbe740
Commit 2ace7a87a8aced68c250 introduced a logic bug by an improperly
fbe740
modified condition where we'd skip to the else branch when reusing of
fbe740
external images was requested and blockdev is available.
fbe740
fbe740
The original intentions were to skip the backing store update with
fbe740
blockdev.
fbe740
fbe740
Fix it by only asserting the boolean which was used to track whether we
fbe740
support update of the backing store only when blockdev is not present
fbe740
along with the appropriate rename.
fbe740
fbe740
https://bugzilla.redhat.com/show_bug.cgi?id=1820016
fbe740
fbe740
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
(cherry picked from commit ae64a75a8713cf14b25b40078766c2da93e001ff)
fbe740
Message-Id: <c4ce185df3fb6d88aa7282d523b0a5c7ccff2aad.1585916255.git.pkrempa@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
---
fbe740
 src/qemu/qemu_driver.c | 19 +++++++++++--------
fbe740
 1 file changed, 11 insertions(+), 8 deletions(-)
fbe740
fbe740
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
fbe740
index 4701a1905e..26215f8d6a 100644
fbe740
--- a/src/qemu/qemu_driver.c
fbe740
+++ b/src/qemu/qemu_driver.c
fbe740
@@ -15403,7 +15403,7 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr driver,
fbe740
 {
fbe740
     virDomainDiskDefPtr persistdisk;
fbe740
     bool supportsCreate;
fbe740
-    bool supportsBacking;
fbe740
+    bool updateRelativeBacking = false;
fbe740
 
fbe740
     dd->disk = disk;
fbe740
 
fbe740
@@ -15432,19 +15432,22 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr driver,
fbe740
     }
fbe740
 
fbe740
     supportsCreate = virStorageFileSupportsCreate(dd->src);
fbe740
-    supportsBacking = virStorageFileSupportsBackingChainTraversal(dd->src);
fbe740
 
fbe740
-    if (supportsCreate || supportsBacking) {
fbe740
+    /* relative backing store paths need to be updated so that relative
fbe740
+     * block commit still works. With blockdev we must update it when doing
fbe740
+     * commit anyways so it's skipped here */
fbe740
+    if (!blockdev &&
fbe740
+        virStorageFileSupportsBackingChainTraversal(dd->src))
fbe740
+        updateRelativeBacking = true;
fbe740
+
fbe740
+    if (supportsCreate || updateRelativeBacking) {
fbe740
         if (qemuDomainStorageFileInit(driver, vm, dd->src, NULL) < 0)
fbe740
             return -1;
fbe740
 
fbe740
         dd->initialized = true;
fbe740
 
fbe740
-        /* relative backing store paths need to be updated so that relative
fbe740
-         * block commit still works. With blockdev we must update it when doing
fbe740
-         * commit anyways so it's skipped here */
fbe740
-        if (reuse && !blockdev) {
fbe740
-            if (supportsBacking) {
fbe740
+        if (reuse) {
fbe740
+            if (updateRelativeBacking) {
fbe740
                 g_autofree char *backingStoreStr = NULL;
fbe740
 
fbe740
                 if (virStorageFileGetBackingStoreStr(dd->src, &backingStoreStr) < 0)
fbe740
-- 
fbe740
2.26.0
fbe740