render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From 615457ad6a27f84b9c1898626dc691fe445ec852 Mon Sep 17 00:00:00 2001
Message-Id: <615457ad6a27f84b9c1898626dc691fe445ec852@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 22 Nov 2017 18:20:49 +0100
Subject: [PATCH] qemu: block commit: Determine relative path of images before
 initializing

Changing labelling of the images does not need to happen after setting
the labeling and lock manager access. This saves the cleanup of the
labeling if the relative path can't be determined.

(cherry picked from commit 3488f449a63994c1a20e08cd6a7fe35de303e77a)

https://bugzilla.redhat.com/show_bug.cgi?id=1516717

This commit simplifies backport of the actual patch, is simple and useful.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_driver.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 46016fb36e..f8df2d452d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17225,19 +17225,6 @@ qemuDomainBlockCommit(virDomainPtr dom,
             goto endjob;
     }
 
-    /* For the commit to succeed, we must allow qemu to open both the
-     * 'base' image and the parent of 'top' as read/write; 'top' might
-     * not have a parent, or might already be read-write.  XXX It
-     * would also be nice to revert 'base' to read-only, as well as
-     * revoke access to files removed from the chain, when the commit
-     * operation succeeds, but doing that requires tracking the
-     * operation in XML across libvirtd restarts.  */
-    clean_access = true;
-    if (qemuDomainDiskChainElementPrepare(driver, vm, baseSource, false) < 0 ||
-        (top_parent && top_parent != disk->src &&
-         qemuDomainDiskChainElementPrepare(driver, vm, top_parent, false) < 0))
-        goto endjob;
-
     if (flags & VIR_DOMAIN_BLOCK_COMMIT_RELATIVE &&
         topSource != disk->src) {
         if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CHANGE_BACKING_FILE)) {
@@ -17257,6 +17244,19 @@ qemuDomainBlockCommit(virDomainPtr dom,
         }
     }
 
+    /* For the commit to succeed, we must allow qemu to open both the
+     * 'base' image and the parent of 'top' as read/write; 'top' might
+     * not have a parent, or might already be read-write.  XXX It
+     * would also be nice to revert 'base' to read-only, as well as
+     * revoke access to files removed from the chain, when the commit
+     * operation succeeds, but doing that requires tracking the
+     * operation in XML across libvirtd restarts.  */
+    clean_access = true;
+    if (qemuDomainDiskChainElementPrepare(driver, vm, baseSource, false) < 0 ||
+        (top_parent && top_parent != disk->src &&
+         qemuDomainDiskChainElementPrepare(driver, vm, top_parent, false) < 0))
+        goto endjob;
+
     /* Start the commit operation.  Pass the user's original spelling,
      * if any, through to qemu, since qemu may behave differently
      * depending on whether the input was specified as relative or
-- 
2.15.1