提交 7c47becf 编写于 作者: J John Ferlan

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: NJohn Ferlan <jferlan@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 28805f3d
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册