[PATCH v2 3/9] qemu: snapshot: Move error preservation to qemuDomainSnapshotDiskDataCleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make qemuDomainSnapshotDiskDataCleanup cleanup section friendly by
moving the error preservation code inside it.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7af3af7809..4f28848dae 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15271,11 +15271,14 @@ qemuDomainSnapshotDiskDataCleanup(qemuDomainSnapshotDiskDataPtr data,
                                   virQEMUDriverPtr driver,
                                   virDomainObjPtr vm)
 {
+    virErrorPtr orig_err;
     size_t i;

     if (!data)
         return;

+    virErrorPreserveLast(&orig_err);
+
     for (i = 0; i < ndata; i++) {
         /* on success of the snapshot the 'src' and 'persistsrc' properties will
          * be set to NULL by qemuDomainSnapshotUpdateDiskSources */
@@ -15299,6 +15302,7 @@ qemuDomainSnapshotDiskDataCleanup(qemuDomainSnapshotDiskDataPtr data,
     }

     VIR_FREE(data);
+    virErrorRestore(&orig_err);
 }


@@ -15503,7 +15507,6 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
     bool reuse = (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) != 0;
     qemuDomainSnapshotDiskDataPtr diskdata = NULL;
     size_t ndiskdata = 0;
-    virErrorPtr orig_err = NULL;

     if (virDomainObjCheckActive(vm) < 0)
         return -1;
@@ -15562,12 +15565,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
     ret = 0;

  cleanup:
-    if (ret < 0)
-        virErrorPreserveLast(&orig_err);
-
     qemuDomainSnapshotDiskDataCleanup(diskdata, ndiskdata, driver, vm);
-    virErrorRestore(&orig_err);
-
     return ret;
 }

-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux