mirror of https://gitee.com/openkylin/libvirt.git
storage: Don't overwrite error in virISCSIDirectDisconnect()
The iscsi-direct storage pool backend works merely like this: a connection is established to the target (usually done via virStorageBackendISCSIDirectSetConnection()), intended action is executed (e.g. reporting LUNs, volume wiping), and at the end the connection is closed via virISCSIDirectDisconnect(). The problem is that virISCSIDirectDisconnect() reports its own errors which may overwrite error that occurred during LUN reporting, or volume wiping or whatever. To fix this, use virErrorPreserveLast() + virErrorRestore() combo, which either preserves previously reported error message, or is NOP if there's no error reported. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1797879 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
07dc1ac9d2
commit
a190906977
|
@ -391,19 +391,28 @@ virISCSIDirectReportLuns(virStoragePoolObj *pool,
|
|||
static int
|
||||
virISCSIDirectDisconnect(struct iscsi_context *iscsi)
|
||||
{
|
||||
virErrorPtr orig_err;
|
||||
int ret = -1;
|
||||
|
||||
virErrorPreserveLast(&orig_err);
|
||||
|
||||
if (iscsi_logout_sync(iscsi) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to logout: %s"),
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
goto cleanup;
|
||||
}
|
||||
if (iscsi_disconnect(iscsi) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to disconnect: %s"),
|
||||
iscsi_get_error(iscsi));
|
||||
return -1;
|
||||
goto cleanup;
|
||||
}
|
||||
return 0;
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virErrorRestore(&orig_err);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
Loading…
Reference in New Issue