aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi-bus.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2011-08-03 10:49:15 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2011-08-12 08:31:05 -0500
commit739df2150d7e6291d54b3d2dcbd9ed52078e991c (patch)
treee18479535801438d789d4e094574330a21c2c630 /hw/scsi-bus.c
parentfdaef06917100d97782df550c1807a1da054e27e (diff)
scsi: move handling of REQUEST SENSE to common code
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/scsi-bus.c')
-rw-r--r--hw/scsi-bus.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 8b229af989..ab45226507 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -270,6 +270,13 @@ static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf)
goto illegal_request;
}
break;
+ case REQUEST_SENSE:
+ if (req->cmd.xfer < 4) {
+ goto illegal_request;
+ }
+ r->len = scsi_device_get_sense(r->req.dev, r->buf, req->cmd.xfer,
+ (req->cmd.buf[1] & 1) == 0);
+ break;
default:
scsi_req_build_sense(req, SENSE_CODE(LUN_NOT_SUPPORTED));
scsi_req_complete(req, CHECK_CONDITION);
@@ -351,8 +358,9 @@ SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun,
cmd.lba);
}
- if ((lun != d->lun && buf[0] != REQUEST_SENSE) ||
- buf[0] == REPORT_LUNS) {
+ if (lun != d->lun ||
+ buf[0] == REPORT_LUNS ||
+ buf[0] == REQUEST_SENSE) {
req = scsi_req_alloc(&reqops_target_command, d, tag, lun,
hba_private);
} else {