[PATCH 04/10] lxc: Use consistent error preservation and restoration calls

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

 



Provide some consistency over error message variable name and usage
when saving error messages across possible other errors or possibility
of resetting of the last error.

Instead of virSaveLastError paired up with virSetError and virFreeError,
we should use the newer virErrorPreserveLast and virRestoreError.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/lxc/lxc_driver.c  | 9 ++++-----
 src/lxc/lxc_process.c | 7 ++-----
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 5c7a9140b2..204a3ed522 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1857,12 +1857,11 @@ static int lxcSetVcpuBWLive(virCgroupPtr cgroup, unsigned long long period,
 
  error:
     if (period) {
-        virErrorPtr saved = virSaveLastError();
+        virErrorPtr saved;
+
+        virErrorPreserveLast(&saved);
         virCgroupSetCpuCfsPeriod(cgroup, old_period);
-        if (saved) {
-            virSetError(saved);
-            virFreeError(saved);
-        }
+        virErrorRestore(&saved);
     }
 
     return -1;
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index da0b055b85..d9939f102d 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -1568,7 +1568,7 @@ int virLXCProcessStart(virConnectPtr conn,
         rc = -1;
     }
     if (rc != 0) {
-        err = virSaveLastError();
+        virErrorPreserveLast(&err);
         virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED);
     }
     virCommandFree(cmd);
@@ -1582,10 +1582,7 @@ int virLXCProcessStart(virConnectPtr conn,
     virObjectUnref(cfg);
     virObjectUnref(caps);
 
-    if (err) {
-        virSetError(err);
-        virFreeError(err);
-    }
+    virErrorRestore(&err);
 
     return rc;
 }
-- 
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