Blame SOURCES/libvirt-qemu-block-commit-Determine-relative-path-of-images-before-initializing.patch

452bec
From 615457ad6a27f84b9c1898626dc691fe445ec852 Mon Sep 17 00:00:00 2001
452bec
Message-Id: <615457ad6a27f84b9c1898626dc691fe445ec852@dist-git>
452bec
From: Peter Krempa <pkrempa@redhat.com>
452bec
Date: Wed, 22 Nov 2017 18:20:49 +0100
452bec
Subject: [PATCH] qemu: block commit: Determine relative path of images before
452bec
 initializing
452bec
452bec
Changing labelling of the images does not need to happen after setting
452bec
the labeling and lock manager access. This saves the cleanup of the
452bec
labeling if the relative path can't be determined.
452bec
452bec
(cherry picked from commit 3488f449a63994c1a20e08cd6a7fe35de303e77a)
452bec
452bec
https://bugzilla.redhat.com/show_bug.cgi?id=1516717
452bec
452bec
This commit simplifies backport of the actual patch, is simple and useful.
452bec
452bec
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
452bec
---
452bec
 src/qemu/qemu_driver.c | 26 +++++++++++++-------------
452bec
 1 file changed, 13 insertions(+), 13 deletions(-)
452bec
452bec
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
452bec
index 46016fb36e..f8df2d452d 100644
452bec
--- a/src/qemu/qemu_driver.c
452bec
+++ b/src/qemu/qemu_driver.c
452bec
@@ -17225,19 +17225,6 @@ qemuDomainBlockCommit(virDomainPtr dom,
452bec
             goto endjob;
452bec
     }
452bec
 
452bec
-    /* For the commit to succeed, we must allow qemu to open both the
452bec
-     * 'base' image and the parent of 'top' as read/write; 'top' might
452bec
-     * not have a parent, or might already be read-write.  XXX It
452bec
-     * would also be nice to revert 'base' to read-only, as well as
452bec
-     * revoke access to files removed from the chain, when the commit
452bec
-     * operation succeeds, but doing that requires tracking the
452bec
-     * operation in XML across libvirtd restarts.  */
452bec
-    clean_access = true;
452bec
-    if (qemuDomainDiskChainElementPrepare(driver, vm, baseSource, false) < 0 ||
452bec
-        (top_parent && top_parent != disk->src &&
452bec
-         qemuDomainDiskChainElementPrepare(driver, vm, top_parent, false) < 0))
452bec
-        goto endjob;
452bec
-
452bec
     if (flags & VIR_DOMAIN_BLOCK_COMMIT_RELATIVE &&
452bec
         topSource != disk->src) {
452bec
         if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CHANGE_BACKING_FILE)) {
452bec
@@ -17257,6 +17244,19 @@ qemuDomainBlockCommit(virDomainPtr dom,
452bec
         }
452bec
     }
452bec
 
452bec
+    /* For the commit to succeed, we must allow qemu to open both the
452bec
+     * 'base' image and the parent of 'top' as read/write; 'top' might
452bec
+     * not have a parent, or might already be read-write.  XXX It
452bec
+     * would also be nice to revert 'base' to read-only, as well as
452bec
+     * revoke access to files removed from the chain, when the commit
452bec
+     * operation succeeds, but doing that requires tracking the
452bec
+     * operation in XML across libvirtd restarts.  */
452bec
+    clean_access = true;
452bec
+    if (qemuDomainDiskChainElementPrepare(driver, vm, baseSource, false) < 0 ||
452bec
+        (top_parent && top_parent != disk->src &&
452bec
+         qemuDomainDiskChainElementPrepare(driver, vm, top_parent, false) < 0))
452bec
+        goto endjob;
452bec
+
452bec
     /* Start the commit operation.  Pass the user's original spelling,
452bec
      * if any, through to qemu, since qemu may behave differently
452bec
      * depending on whether the input was specified as relative or
452bec
-- 
452bec
2.15.1
452bec