mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
network: replace virSaveLastError() with virErrorPreserveLast()
virErrorPreserveLast()/virErrorRestore() (added in commit 8333e7455
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: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
dac697e8d7
commit
39de732aa7
@ -2987,13 +2987,12 @@ networkStartNetwork(virNetworkDriverStatePtr driver,
|
||||
|
||||
cleanup:
|
||||
if (ret < 0) {
|
||||
virErrorPtr save_err;
|
||||
|
||||
virErrorPreserveLast(&save_err);
|
||||
virNetworkObjUnsetDefTransient(obj);
|
||||
virErrorPtr save_err = virSaveLastError();
|
||||
int save_errno = errno;
|
||||
networkShutdownNetwork(driver, obj);
|
||||
virSetError(save_err);
|
||||
virFreeError(save_err);
|
||||
errno = save_errno;
|
||||
virErrorRestore(&save_err);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -5596,13 +5595,13 @@ networkPortCreateXML(virNetworkPtr net,
|
||||
goto cleanup;
|
||||
|
||||
if (virNetworkObjAddPort(obj, portdef, driver->stateDir) < 0) {
|
||||
virErrorPtr saved;
|
||||
virErrorPtr save_err;
|
||||
|
||||
saved = virSaveLastError();
|
||||
virErrorPreserveLast(&save_err);
|
||||
ignore_value(networkReleasePort(obj, portdef));
|
||||
virNetworkPortDefFree(portdef);
|
||||
virSetError(saved);
|
||||
virFreeError(saved);
|
||||
virErrorRestore(&save_err);
|
||||
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user