]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc: Use consistent error preservation and restoration calls
authorJohn Ferlan <jferlan@redhat.com>
Thu, 6 Dec 2018 17:32:37 +0000 (12:32 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 16 Oct 2019 19:24:40 +0000 (15:24 -0400)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/lxc/lxc_driver.c
src/lxc/lxc_process.c

index 5c7a9140b240d3e090390479d5e7054cdff12617..204a3ed522aeb72f7d5282aa7ff36521e68fa675 100644 (file)
@@ -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;
index da0b055b851446fafb1fb0de396d18918d6fec8f..d9939f102d88a4372238f1e3a072a05b64528290 100644 (file)
@@ -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;
 }