提交 39de732a 编写于 作者: L Laine Stump

network: replace virSaveLastError() with virErrorPreserveLast()

virErrorPreserveLast()/virErrorRestore() (added in commit 8333e745
back in 2017), do a better better job of saving and restoring the last
libvirt error than virSaveLastError()/virErrorRestore() (they're
simpler, and they also save/restore the system errno).
Signed-off-by: NLaine Stump <laine@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 dac697e8
...@@ -2987,13 +2987,12 @@ networkStartNetwork(virNetworkDriverStatePtr driver, ...@@ -2987,13 +2987,12 @@ networkStartNetwork(virNetworkDriverStatePtr driver,
cleanup: cleanup:
if (ret < 0) { if (ret < 0) {
virErrorPtr save_err;
virErrorPreserveLast(&save_err);
virNetworkObjUnsetDefTransient(obj); virNetworkObjUnsetDefTransient(obj);
virErrorPtr save_err = virSaveLastError();
int save_errno = errno;
networkShutdownNetwork(driver, obj); networkShutdownNetwork(driver, obj);
virSetError(save_err); virErrorRestore(&save_err);
virFreeError(save_err);
errno = save_errno;
} }
return ret; return ret;
} }
...@@ -5596,13 +5595,13 @@ networkPortCreateXML(virNetworkPtr net, ...@@ -5596,13 +5595,13 @@ networkPortCreateXML(virNetworkPtr net,
goto cleanup; goto cleanup;
if (virNetworkObjAddPort(obj, portdef, driver->stateDir) < 0) { if (virNetworkObjAddPort(obj, portdef, driver->stateDir) < 0) {
virErrorPtr saved; virErrorPtr save_err;
saved = virSaveLastError(); virErrorPreserveLast(&save_err);
ignore_value(networkReleasePort(obj, portdef)); ignore_value(networkReleasePort(obj, portdef));
virNetworkPortDefFree(portdef); virNetworkPortDefFree(portdef);
virSetError(saved); virErrorRestore(&save_err);
virFreeError(saved);
goto cleanup; goto cleanup;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册