]> xenbits.xensource.com Git - libvirt.git/commitdiff
vz: Use consistent error preservation and restoration calls
authorJohn Ferlan <jferlan@redhat.com>
Thu, 6 Dec 2018 17:33:49 +0000 (12:33 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 16 Oct 2019 19:24:41 +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/vz/vz_driver.c

index f8c5232018c4aa5e9e9deb5ebba1a3cb8cf94fe5..21425346ac7a1e10887c209fe42f683b9aece412 100644 (file)
@@ -3206,7 +3206,7 @@ vzDomainMigratePerformP2P(virDomainObjPtr dom,
      */
     if (uri && virTypedParamsReplaceString(&params, &nparams,
                                            VIR_MIGRATE_PARAM_URI, uri) < 0) {
-        orig_err = virSaveLastError();
+        virErrorPreserveLast(&orig_err);
         goto finish;
     }
 
@@ -3216,7 +3216,7 @@ vzDomainMigratePerformP2P(virDomainObjPtr dom,
     cookieoutlen = 0;
     if (vzDomainMigratePerformStep(dom, driver, params, nparams, cookiein,
                                    cookieinlen, flags) < 0) {
-        orig_err = virSaveLastError();
+        virErrorPreserveLast(&orig_err);
         goto finish;
     }
 
@@ -3242,10 +3242,7 @@ vzDomainMigratePerformP2P(virDomainObjPtr dom,
     /* confirm step is NOOP thus no need to call it */
 
  done:
-    if (orig_err) {
-        virSetError(orig_err);
-        virFreeError(orig_err);
-    }
+    virErrorRestore(&orig_err);
     VIR_FREE(dom_xml);
     VIR_FREE(uri);
     VIR_FREE(cookiein);