提交 57a9d2fe 编写于 作者: J John Ferlan

libxl: Use consistent error preservation and restoration calls

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: NJohn Ferlan <jferlan@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 532e9a34
...@@ -1049,7 +1049,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver, ...@@ -1049,7 +1049,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver,
if (uri_out) { if (uri_out) {
if (virTypedParamsReplaceString(&params, &nparams, if (virTypedParamsReplaceString(&params, &nparams,
VIR_MIGRATE_PARAM_URI, uri_out) < 0) { VIR_MIGRATE_PARAM_URI, uri_out) < 0) {
orig_err = virSaveLastError(); virErrorPreserveLast(&orig_err);
goto finish; goto finish;
} }
} else { } else {
...@@ -1067,7 +1067,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver, ...@@ -1067,7 +1067,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver,
uri_out, NULL, flags); uri_out, NULL, flags);
if (ret < 0) { if (ret < 0) {
notify_source = false; notify_source = false;
orig_err = virSaveLastError(); virErrorPreserveLast(&orig_err);
} }
cancelled = (ret < 0); cancelled = (ret < 0);
...@@ -1094,7 +1094,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver, ...@@ -1094,7 +1094,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver,
* one we need to preserve it in case confirm3 overwrites * one we need to preserve it in case confirm3 overwrites
*/ */
if (!orig_err) if (!orig_err)
orig_err = virSaveLastError(); virErrorPreserveLast(&orig_err);
confirm: confirm:
if (notify_source) { if (notify_source) {
...@@ -1119,10 +1119,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver, ...@@ -1119,10 +1119,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver,
ret = -1; ret = -1;
} }
if (orig_err) { virErrorRestore(&orig_err);
virSetError(orig_err);
virFreeError(orig_err);
}
VIR_FREE(cookieout); VIR_FREE(cookieout);
VIR_FREE(dom_xml); VIR_FREE(dom_xml);
...@@ -1200,15 +1197,12 @@ libxlDomainMigrationSrcPerformP2P(libxlDriverPrivatePtr driver, ...@@ -1200,15 +1197,12 @@ libxlDomainMigrationSrcPerformP2P(libxlDriverPrivatePtr driver,
} }
cleanup: cleanup:
orig_err = virSaveLastError(); virErrorPreserveLast(&orig_err);
virObjectUnlock(vm); virObjectUnlock(vm);
virObjectUnref(dconn); virObjectUnref(dconn);
virObjectUnref(cfg); virObjectUnref(cfg);
virObjectLock(vm); virObjectLock(vm);
if (orig_err) { virErrorRestore(&orig_err);
virSetError(orig_err);
virFreeError(orig_err);
}
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册