aboutsummaryrefslogtreecommitdiff
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
parent12010e7b29a2e777153440ded6fd5bd426eed3e4 (diff)
downloadqemu-c39ce112b60ffafbaf700853e32bea74cbb2c148.zip
qemu-c39ce112b60ffafbaf700853e32bea74cbb2c148.tar.gz
qemu-c39ce112b60ffafbaf700853e32bea74cbb2c148.tar.bz2
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>
-rw-r--r--hw/esp.c4
-rw-r--r--hw/lsi53c895a.c4
-rw-r--r--hw/scsi-bus.c13
-rw-r--r--hw/scsi.h4
-rw-r--r--hw/spapr_vscsi.c4
-rw-r--r--hw/usb-msd.c4
6 files changed, 18 insertions, 15 deletions
diff --git a/hw/esp.c b/hw/esp.c
index 9ddd637..be3a35d 100644
--- a/hw/esp.c
+++ b/hw/esp.c
@@ -244,8 +244,8 @@ static void do_busid_cmd(ESPState *s, uint8_t *buf, uint8_t busid)
DPRINTF("do_busid_cmd: busid 0x%x\n", busid);
lun = busid & 7;
- s->current_req = scsi_req_new(s->current_dev, 0, lun, NULL);
- datalen = scsi_req_enqueue(s->current_req, buf);
+ s->current_req = scsi_req_new(s->current_dev, 0, lun, buf, NULL);
+ datalen = scsi_req_enqueue(s->current_req);
s->ti_size = datalen;
if (datalen != 0) {
s->rregs[ESP_RSTAT] = STAT_TC;
diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
index d067a02..41c2fb0 100644
--- a/hw/lsi53c895a.c
+++ b/hw/lsi53c895a.c
@@ -781,10 +781,10 @@ static void lsi_do_command(LSIState *s)
assert(s->current == NULL);
s->current = qemu_mallocz(sizeof(lsi_request));
s->current->tag = s->select_tag;
- s->current->req = scsi_req_new(dev, s->current->tag, s->current_lun,
+ s->current->req = scsi_req_new(dev, s->current->tag, s->current_lun, buf,
s->current);
- n = scsi_req_enqueue(s->current->req, buf);
+ n = scsi_req_enqueue(s->current->req);
if (n) {
if (n > 0) {
lsi_set_phase(s, PHASE_DI);
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index df28cc8..7b5a9ce 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],
diff --git a/hw/scsi.h b/hw/scsi.h
index 5c0e076..7ed7550 100644
--- a/hw/scsi.h
+++ b/hw/scsi.h
@@ -154,8 +154,8 @@ int scsi_sense_valid(SCSISense sense);
SCSIRequest *scsi_req_alloc(SCSIReqOps *reqops, SCSIDevice *d, uint32_t tag,
uint32_t lun, void *hba_private);
SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun,
- void *hba_private);
-int32_t scsi_req_enqueue(SCSIRequest *req, uint8_t *buf);
+ uint8_t *buf, void *hba_private);
+int32_t scsi_req_enqueue(SCSIRequest *req);
void scsi_req_free(SCSIRequest *req);
SCSIRequest *scsi_req_ref(SCSIRequest *req);
void scsi_req_unref(SCSIRequest *req);
diff --git a/hw/spapr_vscsi.c b/hw/spapr_vscsi.c
index c65308c..d98d1fd 100644
--- a/hw/spapr_vscsi.c
+++ b/hw/spapr_vscsi.c
@@ -600,8 +600,8 @@ static int vscsi_queue_cmd(VSCSIState *s, vscsi_req *req)
}
req->lun = lun;
- req->sreq = scsi_req_new(sdev, req->qtag, lun, req);
- n = scsi_req_enqueue(req->sreq, srp->cmd.cdb);
+ req->sreq = scsi_req_new(sdev, req->qtag, lun, srp->cmd.cdb, req);
+ n = scsi_req_enqueue(req->sreq);
dprintf("VSCSI: Queued command tag 0x%x CMD 0x%x ID %d LUN %d ret: %d\n",
req->qtag, srp->cmd.cdb[0], id, lun, n);
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index 90e57fb..4072efd 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -370,8 +370,8 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p)
s->tag, cbw.flags, cbw.cmd_len, s->data_len);
s->residue = 0;
s->scsi_len = 0;
- s->req = scsi_req_new(s->scsi_dev, s->tag, 0, NULL);
- scsi_req_enqueue(s->req, cbw.cmd);
+ s->req = scsi_req_new(s->scsi_dev, s->tag, 0, cbw.cmd, NULL);
+ scsi_req_enqueue(s->req);
/* ??? Should check that USB and SCSI data transfer
directions match. */
if (s->mode != USB_MSDM_CSW && s->residue == 0) {