aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi-bus.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2011-08-03 10:49:10 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2011-08-12 08:27:37 -0500
commitc39ce112b60ffafbaf700853e32bea74cbb2c148 (patch)
tree057c60e24ca46e5c880fe575fc17620c1dff0ea0 /hw/scsi-bus.c
parent12010e7b29a2e777153440ded6fd5bd426eed3e4 (diff)
scsi: pass cdb already to scsi_req_new
Right now the CDB is not passed to the SCSIBus until scsi_req_enqueue. Passing it to scsi_req_new will let scsi_req_new dispatch common requests through different reqops. Moving the memcpy to scsi_req_new is a hack that will go away as soon as scsi_req_new will also take care of the parsing. 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.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index df28cc8982..7b5a9ce09d 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -153,9 +153,12 @@ SCSIRequest *scsi_req_alloc(SCSIReqOps *reqops, SCSIDevice *d, uint32_t tag,
}
SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun,
- void *hba_private)
+ uint8_t *buf, void *hba_private)
{
- return d->info->alloc_req(d, tag, lun, hba_private);
+ SCSIRequest *req;
+ req = d->info->alloc_req(d, tag, lun, hba_private);
+ memcpy(req->cmd.buf, buf, 16);
+ return req;
}
uint8_t *scsi_req_get_buf(SCSIRequest *req)
@@ -189,7 +192,7 @@ void scsi_req_build_sense(SCSIRequest *req, SCSISense sense)
req->sense_len = 18;
}
-int32_t scsi_req_enqueue(SCSIRequest *req, uint8_t *buf)
+int32_t scsi_req_enqueue(SCSIRequest *req)
{
int32_t rc;
@@ -199,7 +202,7 @@ int32_t scsi_req_enqueue(SCSIRequest *req, uint8_t *buf)
QTAILQ_INSERT_TAIL(&req->dev->requests, req, next);
scsi_req_ref(req);
- rc = req->ops->send_command(req, buf);
+ rc = req->ops->send_command(req, req->cmd.buf);
scsi_req_unref(req);
return rc;
}
@@ -431,7 +434,7 @@ int scsi_req_parse(SCSIRequest *req, uint8_t *buf)
if (rc != 0)
return rc;
- memcpy(req->cmd.buf, buf, req->cmd.len);
+ assert(buf == req->cmd.buf);
scsi_req_xfer_mode(req);
req->cmd.lba = scsi_req_lba(req);
trace_scsi_req_parsed(req->dev->id, req->lun, req->tag, buf[0],