]> xenbits.xensource.com Git - libvirt.git/commitdiff
libxl: Use consistent error preservation and restoration calls
authorJohn Ferlan <jferlan@redhat.com>
Thu, 6 Dec 2018 17:32:28 +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/libxl/libxl_migration.c

index 8a41e9374d8c6d76265cff91b45b1dfb032cbc5b..770a300316f7e2af1861ad058b09d06a7110f719 100644 (file)
@@ -1049,7 +1049,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver,
         if (uri_out) {
             if (virTypedParamsReplaceString(&params, &nparams,
                                             VIR_MIGRATE_PARAM_URI, uri_out) < 0) {
-                orig_err = virSaveLastError();
+                virErrorPreserveLast(&orig_err);
                 goto finish;
             }
         } else {
@@ -1067,7 +1067,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver,
                                              uri_out, NULL, flags);
     if (ret < 0) {
         notify_source = false;
-        orig_err = virSaveLastError();
+        virErrorPreserveLast(&orig_err);
     }
 
     cancelled = (ret < 0);
@@ -1094,7 +1094,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver,
      * one we need to preserve it in case confirm3 overwrites
      */
     if (!orig_err)
-        orig_err = virSaveLastError();
+        virErrorPreserveLast(&orig_err);
 
  confirm:
     if (notify_source) {
@@ -1119,10 +1119,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver,
         ret = -1;
     }
 
-    if (orig_err) {
-        virSetError(orig_err);
-        virFreeError(orig_err);
-    }
+    virErrorRestore(&orig_err);
 
     VIR_FREE(cookieout);
     VIR_FREE(dom_xml);
@@ -1200,15 +1197,12 @@ libxlDomainMigrationSrcPerformP2P(libxlDriverPrivatePtr driver,
     }
 
  cleanup:
-    orig_err = virSaveLastError();
+    virErrorPreserveLast(&orig_err);
     virObjectUnlock(vm);
     virObjectUnref(dconn);
     virObjectUnref(cfg);
     virObjectLock(vm);
-    if (orig_err) {
-        virSetError(orig_err);
-        virFreeError(orig_err);
-    }
+    virErrorRestore(&orig_err);
     return ret;
 }