aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi-disk.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2011-08-03 10:49:08 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2011-08-12 08:27:36 -0500
commit8dbd4574882cade8261c2b6225df68a65345c75c (patch)
tree59101dbc9f0c5d838294da898122fe6e0c59881f /hw/scsi-disk.c
parentb45ef674f4c403398e75c6be02e27a0bfa813a11 (diff)
scsi: introduce SCSIReqOps
This will let allow requests to be dispatched through different callbacks, either common or per-device. This patch adjusts the API, the next one will move members to SCSIReqOps. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/scsi-disk.c')
-rw-r--r--hw/scsi-disk.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index e266d6fe9a..dddc1f3cd5 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -76,19 +76,6 @@ struct SCSIDiskState
static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type);
static int scsi_disk_emulate_command(SCSIDiskReq *r, uint8_t *outbuf);
-static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag,
- uint32_t lun, void *hba_private)
-{
- SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d);
- SCSIRequest *req;
- SCSIDiskReq *r;
-
- req = scsi_req_alloc(sizeof(SCSIDiskReq), &s->qdev, tag, lun, hba_private);
- r = DO_UPCAST(SCSIDiskReq, req, req);
- r->iov.iov_base = qemu_blockalign(s->bs, SCSI_DMA_BUF_SIZE);
- return req;
-}
-
static void scsi_free_request(SCSIRequest *req)
{
SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
@@ -1225,6 +1212,23 @@ static int scsi_disk_initfn(SCSIDevice *dev)
return scsi_initfn(dev, scsi_type);
}
+static SCSIReqOps scsi_disk_reqops = {
+ .size = sizeof(SCSIDiskReq),
+};
+
+static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag,
+ uint32_t lun, void *hba_private)
+{
+ SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d);
+ SCSIRequest *req;
+ SCSIDiskReq *r;
+
+ req = scsi_req_alloc(&scsi_disk_reqops, &s->qdev, tag, lun, hba_private);
+ r = DO_UPCAST(SCSIDiskReq, req, req);
+ r->iov.iov_base = qemu_blockalign(s->bs, SCSI_DMA_BUF_SIZE);
+ return req;
+}
+
#define DEFINE_SCSI_DISK_PROPERTIES() \
DEFINE_BLOCK_PROPERTIES(SCSIDiskState, qdev.conf), \
DEFINE_PROP_STRING("ver", SCSIDiskState, version), \