Skip to content

Commit

Permalink
scsi: fix sense code for EREMOTEIO
Browse files Browse the repository at this point in the history
SENSE_CODE(LUN_COMM_FAILURE) has an ABORTED COMMAND sense key,
so it results in a retry in Linux.  To ensure that EREMOTEIO
is forwarded to the guest, use a HARDWARE ERROR sense key
instead.  Note that the code before commit d7a8402 was incorrect
because it used HARDWARE_ERROR as a SCSI status, not as a sense
key.

Reported-by: Marc-André Lureau <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
bonzini committed Mar 16, 2021
1 parent 26dbec4 commit dc293f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scsi/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ int scsi_sense_from_errno(int errno_value, SCSISense *sense)
return TASK_SET_FULL;
#ifdef CONFIG_LINUX
/* These errno mapping are specific to Linux. For more information:
* - scsi_decide_disposition in drivers/scsi/scsi_error.c
* - scsi_check_sense and scsi_decide_disposition in drivers/scsi/scsi_error.c
* - scsi_result_to_blk_status in drivers/scsi/scsi_lib.c
* - blk_errors[] in block/blk-core.c
*/
Expand All @@ -599,7 +599,7 @@ int scsi_sense_from_errno(int errno_value, SCSISense *sense)
*sense = SENSE_CODE(READ_ERROR);
return CHECK_CONDITION;
case EREMOTEIO:
*sense = SENSE_CODE(LUN_COMM_FAILURE);
*sense = SENSE_CODE(TARGET_FAILURE);
return CHECK_CONDITION;
#endif
case ENOMEDIUM:
Expand Down

0 comments on commit dc293f6

Please sign in to comment.