render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From 8fc980241464db978fad2e86bc3d6916a173cbe9 Mon Sep 17 00:00:00 2001
Message-Id: <8fc980241464db978fad2e86bc3d6916a173cbe9@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 22 Nov 2017 18:20:48 +0100
Subject: [PATCH] qemu: block commit: Don't overwrite error when rolling back
 disk labels

Calls to qemuDomainDiskChainElementPrepare resets the original error,
thus we need to save it in the cleanup path of qemuDomainBlockCommit.

(cherry picked from commit c885b7fe1de1961391a117c033b4012a02cc8fca)

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

Helps resolve merge conflicts with the actual patch and is useful by
itself.

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

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index bfd7ff6c09..46016fb36e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17302,10 +17302,16 @@ qemuDomainBlockCommit(virDomainPtr dom,
 
  endjob:
     if (ret < 0 && clean_access) {
+        virErrorPtr orig_err = virSaveLastError();
         /* Revert access to read-only, if possible.  */
         qemuDomainDiskChainElementPrepare(driver, vm, baseSource, true);
         if (top_parent && top_parent != disk->src)
             qemuDomainDiskChainElementPrepare(driver, vm, top_parent, true);
+
+        if (orig_err) {
+            virSetError(orig_err);
+            virFreeError(orig_err);
+        }
     }
     virStorageSourceFree(mirror);
     qemuDomainObjEndJob(driver, vm);
-- 
2.15.1