|
|
9bac43 |
From 23f2b51d8b3d7734718eb2f9b109cb9090f1484e Mon Sep 17 00:00:00 2001
|
|
|
9bac43 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
Date: Sat, 2 Dec 2017 12:19:39 +0100
|
|
|
9bac43 |
Subject: [PATCH 13/36] scsi-bus: correct responses for INQUIRY and REQUEST
|
|
|
9bac43 |
SENSE
|
|
|
9bac43 |
|
|
|
9bac43 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
Message-id: <20171202121953.13317-4-pbonzini@redhat.com>
|
|
|
9bac43 |
Patchwork-id: 78085
|
|
|
9bac43 |
O-Subject: [RHEL7.4 qemu-kvm-rhev PATCH 03/17] scsi-bus: correct responses for INQUIRY and REQUEST SENSE
|
|
|
9bac43 |
Bugzilla: 1464908
|
|
|
9bac43 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
From: Hannes Reinecke <hare@suse.de>
|
|
|
9bac43 |
|
|
|
9bac43 |
According to SPC-3 INQUIRY and REQUEST SENSE should return GOOD
|
|
|
9bac43 |
even on unsupported LUNS.
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: Hannes Reinecke <hare@suse.com>
|
|
|
9bac43 |
Message-Id: <1503049022-14749-1-git-send-email-hare@suse.de>
|
|
|
9bac43 |
Reported-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9bac43 |
Fixes: ded6ddc5a7b95217557fa360913d1213e12d4a6d
|
|
|
9bac43 |
Cc: qemu-stable@nongnu.org
|
|
|
9bac43 |
Signed-off-by: Hannes Reinecke <hare@suse.de>
|
|
|
9bac43 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
(cherry picked from commit b07fbce6349c7b84642e7ed56c7a1ac3c1caca61)
|
|
|
9bac43 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9bac43 |
---
|
|
|
9bac43 |
hw/scsi/scsi-bus.c | 29 +++++++++++++++++++++++++----
|
|
|
9bac43 |
1 file changed, 25 insertions(+), 4 deletions(-)
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
|
|
|
9bac43 |
index 404686a..55aa5a7 100644
|
|
|
9bac43 |
--- a/hw/scsi/scsi-bus.c
|
|
|
9bac43 |
+++ b/hw/scsi/scsi-bus.c
|
|
|
9bac43 |
@@ -524,8 +524,10 @@ static size_t scsi_sense_len(SCSIRequest *req)
|
|
|
9bac43 |
static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf)
|
|
|
9bac43 |
{
|
|
|
9bac43 |
SCSITargetReq *r = DO_UPCAST(SCSITargetReq, req, req);
|
|
|
9bac43 |
+ int fixed_sense = (req->cmd.buf[1] & 1) == 0;
|
|
|
9bac43 |
|
|
|
9bac43 |
- if (req->lun != 0) {
|
|
|
9bac43 |
+ if (req->lun != 0 &&
|
|
|
9bac43 |
+ buf[0] != INQUIRY && buf[0] != REQUEST_SENSE) {
|
|
|
9bac43 |
scsi_req_build_sense(req, SENSE_CODE(LUN_NOT_SUPPORTED));
|
|
|
9bac43 |
scsi_req_complete(req, CHECK_CONDITION);
|
|
|
9bac43 |
return 0;
|
|
|
9bac43 |
@@ -543,9 +545,28 @@ static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf)
|
|
|
9bac43 |
break;
|
|
|
9bac43 |
case REQUEST_SENSE:
|
|
|
9bac43 |
scsi_target_alloc_buf(&r->req, scsi_sense_len(req));
|
|
|
9bac43 |
- r->len = scsi_device_get_sense(r->req.dev, r->buf,
|
|
|
9bac43 |
- MIN(req->cmd.xfer, r->buf_len),
|
|
|
9bac43 |
- (req->cmd.buf[1] & 1) == 0);
|
|
|
9bac43 |
+ if (req->lun != 0) {
|
|
|
9bac43 |
+ const struct SCSISense sense = SENSE_CODE(LUN_NOT_SUPPORTED);
|
|
|
9bac43 |
+
|
|
|
9bac43 |
+ if (fixed_sense) {
|
|
|
9bac43 |
+ r->buf[0] = 0x70;
|
|
|
9bac43 |
+ r->buf[2] = sense.key;
|
|
|
9bac43 |
+ r->buf[10] = 10;
|
|
|
9bac43 |
+ r->buf[12] = sense.asc;
|
|
|
9bac43 |
+ r->buf[13] = sense.ascq;
|
|
|
9bac43 |
+ r->len = MIN(req->cmd.xfer, SCSI_SENSE_LEN);
|
|
|
9bac43 |
+ } else {
|
|
|
9bac43 |
+ r->buf[0] = 0x72;
|
|
|
9bac43 |
+ r->buf[1] = sense.key;
|
|
|
9bac43 |
+ r->buf[2] = sense.asc;
|
|
|
9bac43 |
+ r->buf[3] = sense.ascq;
|
|
|
9bac43 |
+ r->len = 8;
|
|
|
9bac43 |
+ }
|
|
|
9bac43 |
+ } else {
|
|
|
9bac43 |
+ r->len = scsi_device_get_sense(r->req.dev, r->buf,
|
|
|
9bac43 |
+ MIN(req->cmd.xfer, r->buf_len),
|
|
|
9bac43 |
+ fixed_sense);
|
|
|
9bac43 |
+ }
|
|
|
9bac43 |
if (r->req.dev->sense_is_ua) {
|
|
|
9bac43 |
scsi_device_unit_attention_reported(req->dev);
|
|
|
9bac43 |
r->req.dev->sense_len = 0;
|
|
|
9bac43 |
--
|
|
|
9bac43 |
1.8.3.1
|
|
|
9bac43 |
|