summaryrefslogtreecommitdiffstats
path: root/hw
diff options
context:
space:
mode:
authorHannes Reinecke2017-08-04 10:36:34 +0200
committerPaolo Bonzini2017-08-08 10:40:20 +0200
commitded6ddc5a7b95217557fa360913d1213e12d4a6d (patch)
tree1496e5859ea9a00b4a312f564df8e5d870c5bd8e /hw
parentkvm: workaround build break on gcc-7.1.1 / fedora26 (diff)
downloadqemu-ded6ddc5a7b95217557fa360913d1213e12d4a6d.tar.gz
qemu-ded6ddc5a7b95217557fa360913d1213e12d4a6d.tar.xz
qemu-ded6ddc5a7b95217557fa360913d1213e12d4a6d.zip
scsi: clarify sense codes for LUN0 emulation
The LUN0 emulation is just that, an emulation for a non-existing LUN0. So we should be returning LUN_NOT_SUPPORTED for any request coming from any other LUN. And we should be aborting unhandled commands with INVALID OPCODE, not LUN NOT SUPPORTED. Signed-off-by: Hannes Reinecke <hare@suse.com> Message-Id: <1501835795-92331-4-git-send-email-hare@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/scsi/scsi-bus.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 23c51de66a..e364410a23 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -517,6 +517,11 @@ static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf)
{
SCSITargetReq *r = DO_UPCAST(SCSITargetReq, req, req);
+ if (req->lun != 0) {
+ scsi_req_build_sense(req, SENSE_CODE(LUN_NOT_SUPPORTED));
+ scsi_req_complete(req, CHECK_CONDITION);
+ return 0;
+ }
switch (buf[0]) {
case REPORT_LUNS:
if (!scsi_target_emulate_report_luns(r)) {
@@ -542,7 +547,7 @@ static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf)
case TEST_UNIT_READY:
break;
default:
- scsi_req_build_sense(req, SENSE_CODE(LUN_NOT_SUPPORTED));
+ scsi_req_build_sense(req, SENSE_CODE(INVALID_OPCODE));
scsi_req_complete(req, CHECK_CONDITION);
return 0;
illegal_request: