[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/7] scsi-disk: convert more errno values back to SCSI statuses
From: |
Hannes Reinecke |
Subject: |
[PATCH 3/7] scsi-disk: convert more errno values back to SCSI statuses |
Date: |
Mon, 16 Nov 2020 19:40:37 +0100 |
From: Paolo Bonzini <pbonzini@redhat.com>
Linux has some OS-specific (and sometimes weird) mappings for various SCSI
statuses and sense codes. The most important is probably RESERVATION
CONFLICT. Add them so that they can be reported back to the guest
kernel.
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/scsi/scsi-disk.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 5d6c892f29..797779afd6 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -460,6 +460,25 @@ static bool scsi_handle_rw_error(SCSIDiskReq *r, int
error, bool acct_failed)
}
error = scsi_sense_buf_to_errno(r->req.sense,
sizeof(r->req.sense));
break;
+#ifdef CONFIG_LINUX
+ /* These errno mapping are specific to Linux. For more
information:
+ * - 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
+ */
+ case EBADE:
+ /* DID_NEXUS_FAILURE -> BLK_STS_NEXUS. */
+ scsi_req_complete(&r->req, RESERVATION_CONFLICT);
+ break;
+ case ENODATA:
+ /* DID_MEDIUM_ERROR -> BLK_STS_MEDIUM. */
+ scsi_check_condition(r, SENSE_CODE(READ_ERROR));
+ break;
+ case EREMOTEIO:
+ /* DID_TARGET_FAILURE -> BLK_STS_TARGET. */
+ scsi_req_complete(&r->req, HARDWARE_ERROR);
+ break;
+#endif
case ENOMEDIUM:
scsi_check_condition(r, SENSE_CODE(NO_MEDIUM));
break;
--
2.16.4
[PATCH 3/7] scsi-disk: convert more errno values back to SCSI statuses,
Hannes Reinecke <=
[PATCH 2/7] scsi: drop 'result' argument from command_complete callback, Hannes Reinecke, 2020/11/16
[PATCH 4/7] scsi: Rename linux-specific SG_ERR codes to generic SCSI_HOST error codes, Hannes Reinecke, 2020/11/16
[PATCH 7/7] scsi: move host_status handling into SCSI drivers, Hannes Reinecke, 2020/11/16
- Re: [PATCH 7/7] scsi: move host_status handling into SCSI drivers, Paolo Bonzini, 2020/11/16
- Re: [PATCH 7/7] scsi: move host_status handling into SCSI drivers, Hannes Reinecke, 2020/11/16
- Re: [PATCH 7/7] scsi: move host_status handling into SCSI drivers, Paolo Bonzini, 2020/11/16
- Re: [PATCH 7/7] scsi: move host_status handling into SCSI drivers, Hannes Reinecke, 2020/11/17
- Re: [PATCH 7/7] scsi: move host_status handling into SCSI drivers, Paolo Bonzini, 2020/11/17
- Re: [PATCH 7/7] scsi: move host_status handling into SCSI drivers, Hannes Reinecke, 2020/11/17
- Re: [PATCH 7/7] scsi: move host_status handling into SCSI drivers, Paolo Bonzini, 2020/11/17