[PATCH v1] qemu: Convert to virErrorPreserveLast/virErrorRestore

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

 



Replaced usage of virSaveLastError and virSetError/virFreeError with
virErrorPreserveLast and virErrorRestore respectively.

Signed-off-by: Syed Humaid <syedhumaidbinharoon@xxxxxxxxx>
---
 src/qemu/qemu_cgroup.c  |  7 ++-----
 src/qemu/qemu_command.c |  2 +-
 src/qemu/qemu_domain.c  |  2 +-
 src/qemu/qemu_driver.c  | 28 ++++++++--------------------
 4 files changed, 12 insertions(+), 27 deletions(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index ca76c4fdfa..c8d9ae4808 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -1123,10 +1123,7 @@ qemuSetupCgroupVcpuBW(virCgroupPtr cgroup,
     if (period) {
         virErrorPtr saved = virSaveLastError();
         ignore_value(virCgroupSetCpuCfsPeriod(cgroup, old_period));
-        if (saved) {
-            virSetError(saved);
-            virFreeError(saved);
-        }
+        virErrorRestore(&saved);
     }
 
     return -1;
@@ -1334,7 +1331,7 @@ qemuCgroupEmulatorAllNodesRestore(qemuCgroupEmulatorAllNodesDataPtr data)
     if (!data)
         return;
 
-    err = virSaveLastError();
+    virErrorPreserveLast(&err);
     virCgroupSetCpusetMems(data->emulatorCgroup, data->emulatorMemMask);
     virSetError(err);
     virFreeError(err);
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 1425d97b1e..9772e4f9af 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9119,7 +9119,7 @@ qemuBuildNetCommandLine(virQEMUDriverPtr driver,
  error:
     /* free up any resources in the network driver
      * but don't overwrite the original error */
-    originalError = virSaveLastError();
+    virErrorPreserveLast(&originalError);
     for (i = 0; last_good_net != -1 && i <= last_good_net; i++)
         virDomainConfNWFilterTeardown(def->nets[i]);
     virSetError(originalError);
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 960aaff3c7..dff1d7b1a5 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8042,7 +8042,7 @@ void qemuDomainObjTaint(virQEMUDriverPtr driver,
     /* We don't care about errors logging taint info, so
      * preserve original error, and clear any error that
      * is raised */
-    orig_err = virSaveLastError();
+    virErrorPreserveLast(&orig_err);
 
     if (!(timestamp = virTimeStringNow()))
         goto cleanup;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f48d9256e4..51b16f5aa1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6844,7 +6844,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
              * must manually kill it and ignore any error related to
              * the process
              */
-            orig_err = virSaveLastError();
+            virErrorPreserveLast(&orig_err);
             VIR_FORCE_CLOSE(intermediatefd);
             VIR_FORCE_CLOSE(*fd);
         }
@@ -6855,10 +6855,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
         }
         VIR_DEBUG("Decompression binary stderr: %s", NULLSTR(errbuf));
 
-        if (orig_err) {
-            virSetError(orig_err);
-            virFreeError(orig_err);
-        }
+        virErrorRestore(&orig_err);
     }
     VIR_FORCE_CLOSE(intermediatefd);
 
@@ -14398,7 +14395,7 @@ qemuDomainSnapshotFSThaw(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
 
     agent = qemuDomainObjEnterAgent(vm);
     if (!report)
-        err = virSaveLastError();
+        virErrorPreserveLast(&err); 
     thawed = qemuAgentFSThaw(agent);
     if (!report)
         virSetError(err);
@@ -15308,7 +15305,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
 
  error:
     if (ret < 0) {
-        orig_err = virSaveLastError();
+        virErrorPreserveLast(&orig_err);
         for (i = 0; i < snapdef->ndisks; i++) {
             if (!diskdata[i].src)
                 continue;
@@ -15351,10 +15348,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
     virJSONValueFree(actions);
     virObjectUnref(cfg);
 
-    if (orig_err) {
-        virSetError(orig_err);
-        virFreeError(orig_err);
-    }
+    virErrorRestore(&orig_err);
 
     return ret;
 }
@@ -17773,7 +17767,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         ret = -1;
     if (ret < 0) {
-        monitor_error = virSaveLastError();
+        virErrorPreserveLast(&monitor_error);
         qemuDomainDiskChainElementRevoke(driver, vm, mirror);
         goto endjob;
     }
@@ -17795,10 +17789,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
         VIR_WARN("%s", _("unable to remove just-created copy target"));
     virStorageFileDeinit(mirror);
     qemuDomainObjEndJob(driver, vm);
-    if (monitor_error) {
-        virSetError(monitor_error);
-        virFreeError(monitor_error);
-    }
+    virErrorRestore(&monitor_error);
     qemuBlockJobStartupFinalize(job);
 
  cleanup:
@@ -18196,10 +18187,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
         if (top_parent && top_parent != disk->src)
             qemuDomainDiskChainElementPrepare(driver, vm, top_parent, true, false);
 
-        if (orig_err) {
-            virSetError(orig_err);
-            virFreeError(orig_err);
-        }
+        virErrorRestore(&orig_err);
     }
     qemuBlockJobStartupFinalize(job);
     qemuDomainObjEndJob(driver, vm);
-- 
2.20.1

--
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