Commit ded6ddc5 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Paolo Bonzini

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: 's avatarHannes Reinecke <hare@suse.com>
Message-Id: <1501835795-92331-4-git-send-email-hare@suse.de>
Signed-off-by: 's avatarPaolo Bonzini <pbonzini@redhat.com>
parent 1b7ac7ca
...@@ -517,6 +517,11 @@ static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf) ...@@ -517,6 +517,11 @@ static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf)
{ {
SCSITargetReq *r = DO_UPCAST(SCSITargetReq, req, req); 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]) { switch (buf[0]) {
case REPORT_LUNS: case REPORT_LUNS:
if (!scsi_target_emulate_report_luns(r)) { if (!scsi_target_emulate_report_luns(r)) {
...@@ -542,7 +547,7 @@ static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf) ...@@ -542,7 +547,7 @@ static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf)
case TEST_UNIT_READY: case TEST_UNIT_READY:
break; break;
default: 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); scsi_req_complete(req, CHECK_CONDITION);
return 0; return 0;
illegal_request: illegal_request:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment