mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
storage: 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: John Ferlan <jferlan@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
28805f3d86
commit
7c47becf76
@ -918,10 +918,9 @@ virStorageBackendDiskCreateVol(virStoragePoolObjPtr pool,
|
||||
/* Best effort to remove the partition. Ignore any errors
|
||||
* since we could be calling this with vol->target.path == NULL
|
||||
*/
|
||||
save_err = virSaveLastError();
|
||||
virErrorPreserveLast(&save_err);
|
||||
ignore_value(virStorageBackendDiskDeleteVol(pool, vol, 0));
|
||||
virSetError(save_err);
|
||||
virFreeError(save_err);
|
||||
virErrorRestore(&save_err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -969,10 +969,9 @@ virStorageBackendLogicalCreateVol(virStoragePoolObjPtr pool,
|
||||
return 0;
|
||||
|
||||
error:
|
||||
err = virSaveLastError();
|
||||
virErrorPreserveLast(&err);
|
||||
virStorageBackendLogicalDeleteVol(pool, vol, 0);
|
||||
virSetError(err);
|
||||
virFreeError(err);
|
||||
virErrorRestore(&err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -81,18 +81,16 @@ storagePoolRefreshFailCleanup(virStorageBackendPtr backend,
|
||||
virStoragePoolObjPtr obj,
|
||||
const char *stateFile)
|
||||
{
|
||||
virErrorPtr orig_err = virSaveLastError();
|
||||
virErrorPtr orig_err;
|
||||
|
||||
virErrorPreserveLast(&orig_err);
|
||||
virStoragePoolObjClearVols(obj);
|
||||
|
||||
if (stateFile)
|
||||
unlink(stateFile);
|
||||
if (backend->stopPool)
|
||||
backend->stopPool(obj);
|
||||
if (orig_err) {
|
||||
virSetError(orig_err);
|
||||
virFreeError(orig_err);
|
||||
}
|
||||
virErrorRestore(&orig_err);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user