|
Paolo Bonzini |
0fb2b2 |
From b07725e3e5e05610691815ee921a6b3307685815 Mon Sep 17 00:00:00 2001
|
|
Paolo Bonzini |
0fb2b2 |
From: Hannes Reinecke <hare@suse.de>
|
|
Paolo Bonzini |
0fb2b2 |
Date: Fri, 18 Aug 2017 11:37:02 +0200
|
|
Paolo Bonzini |
0fb2b2 |
Subject: [PATCH 03/15] scsi-bus: correct responses for INQUIRY and REQUEST
|
|
Paolo Bonzini |
0fb2b2 |
SENSE
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
According to SPC-3 INQUIRY and REQUEST SENSE should return GOOD
|
|
Paolo Bonzini |
0fb2b2 |
even on unsupported LUNS.
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
Signed-off-by: Hannes Reinecke <hare@suse.com>
|
|
Paolo Bonzini |
0fb2b2 |
Message-Id: <1503049022-14749-1-git-send-email-hare@suse.de>
|
|
Paolo Bonzini |
0fb2b2 |
Reported-by: Laszlo Ersek <lersek@redhat.com>
|
|
Paolo Bonzini |
0fb2b2 |
Fixes: ded6ddc5a7b95217557fa360913d1213e12d4a6d
|
|
Paolo Bonzini |
0fb2b2 |
Cc: qemu-stable@nongnu.org
|
|
Paolo Bonzini |
0fb2b2 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
Paolo Bonzini |
0fb2b2 |
Signed-off-by: Hannes Reinecke <hare@suse.de>
|
|
Paolo Bonzini |
0fb2b2 |
---
|
|
Paolo Bonzini |
0fb2b2 |
hw/scsi/scsi-bus.c | 29 +++++++++++++++++++++++++----
|
|
Paolo Bonzini |
0fb2b2 |
1 file changed, 25 insertions(+), 4 deletions(-)
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
|
|
Paolo Bonzini |
0fb2b2 |
index e364410a23..ade31c11f5 100644
|
|
Paolo Bonzini |
0fb2b2 |
--- a/hw/scsi/scsi-bus.c
|
|
Paolo Bonzini |
0fb2b2 |
+++ b/hw/scsi/scsi-bus.c
|
|
Paolo Bonzini |
0fb2b2 |
@@ -516,8 +516,10 @@ static size_t scsi_sense_len(SCSIRequest *req)
|
|
Paolo Bonzini |
0fb2b2 |
static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf)
|
|
Paolo Bonzini |
0fb2b2 |
{
|
|
Paolo Bonzini |
0fb2b2 |
SCSITargetReq *r = DO_UPCAST(SCSITargetReq, req, req);
|
|
Paolo Bonzini |
0fb2b2 |
+ int fixed_sense = (req->cmd.buf[1] & 1) == 0;
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
- if (req->lun != 0) {
|
|
Paolo Bonzini |
0fb2b2 |
+ if (req->lun != 0 &&
|
|
Paolo Bonzini |
0fb2b2 |
+ buf[0] != INQUIRY && buf[0] != REQUEST_SENSE) {
|
|
Paolo Bonzini |
0fb2b2 |
scsi_req_build_sense(req, SENSE_CODE(LUN_NOT_SUPPORTED));
|
|
Paolo Bonzini |
0fb2b2 |
scsi_req_complete(req, CHECK_CONDITION);
|
|
Paolo Bonzini |
0fb2b2 |
return 0;
|
|
Paolo Bonzini |
0fb2b2 |
@@ -535,9 +537,28 @@ static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf)
|
|
Paolo Bonzini |
0fb2b2 |
break;
|
|
Paolo Bonzini |
0fb2b2 |
case REQUEST_SENSE:
|
|
Paolo Bonzini |
0fb2b2 |
scsi_target_alloc_buf(&r->req, scsi_sense_len(req));
|
|
Paolo Bonzini |
0fb2b2 |
- r->len = scsi_device_get_sense(r->req.dev, r->buf,
|
|
Paolo Bonzini |
0fb2b2 |
- MIN(req->cmd.xfer, r->buf_len),
|
|
Paolo Bonzini |
0fb2b2 |
- (req->cmd.buf[1] & 1) == 0);
|
|
Paolo Bonzini |
0fb2b2 |
+ if (req->lun != 0) {
|
|
Paolo Bonzini |
0fb2b2 |
+ const struct SCSISense sense = SENSE_CODE(LUN_NOT_SUPPORTED);
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ if (fixed_sense) {
|
|
Paolo Bonzini |
0fb2b2 |
+ r->buf[0] = 0x70;
|
|
Paolo Bonzini |
0fb2b2 |
+ r->buf[2] = sense.key;
|
|
Paolo Bonzini |
0fb2b2 |
+ r->buf[10] = 10;
|
|
Paolo Bonzini |
0fb2b2 |
+ r->buf[12] = sense.asc;
|
|
Paolo Bonzini |
0fb2b2 |
+ r->buf[13] = sense.ascq;
|
|
Paolo Bonzini |
0fb2b2 |
+ r->len = MIN(req->cmd.xfer, SCSI_SENSE_LEN);
|
|
Paolo Bonzini |
0fb2b2 |
+ } else {
|
|
Paolo Bonzini |
0fb2b2 |
+ r->buf[0] = 0x72;
|
|
Paolo Bonzini |
0fb2b2 |
+ r->buf[1] = sense.key;
|
|
Paolo Bonzini |
0fb2b2 |
+ r->buf[2] = sense.asc;
|
|
Paolo Bonzini |
0fb2b2 |
+ r->buf[3] = sense.ascq;
|
|
Paolo Bonzini |
0fb2b2 |
+ r->len = 8;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+ } else {
|
|
Paolo Bonzini |
0fb2b2 |
+ r->len = scsi_device_get_sense(r->req.dev, r->buf,
|
|
Paolo Bonzini |
0fb2b2 |
+ MIN(req->cmd.xfer, r->buf_len),
|
|
Paolo Bonzini |
0fb2b2 |
+ fixed_sense);
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
if (r->req.dev->sense_is_ua) {
|
|
Paolo Bonzini |
0fb2b2 |
scsi_device_unit_attention_reported(req->dev);
|
|
Paolo Bonzini |
0fb2b2 |
r->req.dev->sense_len = 0;
|
|
Paolo Bonzini |
0fb2b2 |
--
|
|
Paolo Bonzini |
0fb2b2 |
2.13.5
|
|
Paolo Bonzini |
0fb2b2 |
|