diff options
author | Hannes Reinecke <hare@suse.de> | 2021-02-24 19:14:50 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-03-06 11:42:57 +0100 |
commit | f3126d65b393c015e8f87763fdccee99bb1119af (patch) | |
tree | 55e3593634cbaadde5e1a74f7c2d0e43c8001dd1 /hw/scsi/vmw_pvscsi.c | |
parent | a108557bbff8a3f44233982f015f996426411be8 (diff) | |
download | qemu-f3126d65b393c015e8f87763fdccee99bb1119af.zip qemu-f3126d65b393c015e8f87763fdccee99bb1119af.tar.gz qemu-f3126d65b393c015e8f87763fdccee99bb1119af.tar.bz2 |
scsi: move host_status handling into SCSI drivers
Some SCSI drivers like virtio have an internal mapping for the
host_status. This patch moves the host_status translation into
the SCSI drivers to allow those drivers to set up the correct
values.
Signed-off-by: Hannes Reinecke <hare@suse.de>.
[Added default handling to avoid touching all drivers. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/scsi/vmw_pvscsi.c')
-rw-r--r-- | hw/scsi/vmw_pvscsi.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c index 0da378e..1f30cb0 100644 --- a/hw/scsi/vmw_pvscsi.c +++ b/hw/scsi/vmw_pvscsi.c @@ -511,6 +511,44 @@ pvscsi_write_sense(PVSCSIRequest *r, uint8_t *sense, int len) } static void +pvscsi_command_failed(SCSIRequest *req) +{ + PVSCSIRequest *pvscsi_req = req->hba_private; + PVSCSIState *s; + + if (!pvscsi_req) { + trace_pvscsi_command_complete_not_found(req->tag); + return; + } + s = pvscsi_req->dev; + + switch (req->host_status) { + case SCSI_HOST_NO_LUN: + pvscsi_req->cmp.hostStatus = BTSTAT_LUNMISMATCH; + break; + case SCSI_HOST_BUSY: + pvscsi_req->cmp.hostStatus = BTSTAT_ABORTQUEUE; + break; + case SCSI_HOST_TIME_OUT: + case SCSI_HOST_ABORTED: + pvscsi_req->cmp.hostStatus = BTSTAT_SENTRST; + break; + case SCSI_HOST_BAD_RESPONSE: + pvscsi_req->cmp.hostStatus = BTSTAT_SELTIMEO; + break; + case SCSI_HOST_RESET: + pvscsi_req->cmp.hostStatus = BTSTAT_BUSRESET; + break; + default: + pvscsi_req->cmp.hostStatus = BTSTAT_HASOFTWARE; + break; + } + pvscsi_req->cmp.scsiStatus = GOOD; + qemu_sglist_destroy(&pvscsi_req->sgl); + pvscsi_complete_request(s, pvscsi_req); +} + +static void pvscsi_command_complete(SCSIRequest *req, size_t resid) { PVSCSIRequest *pvscsi_req = req->hba_private; @@ -1103,6 +1141,7 @@ static const struct SCSIBusInfo pvscsi_scsi_info = { .get_sg_list = pvscsi_get_sg_list, .complete = pvscsi_command_complete, .cancel = pvscsi_request_cancelled, + .fail = pvscsi_command_failed, }; static void |