aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi-bus.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-11-26 15:33:50 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-12-03 09:41:36 -0600
commit89b08ae15449fe433325061ebb928766a1c77381 (patch)
tree87543c67167a00d0d2d1b60e940b6afc6c41a3fc /hw/scsi-bus.c
parent9af99d980e9ff6270f291b11a064087b33dd3ab8 (diff)
scsi: move SCSIRequest management to common code.
Create generic functions to allocate, find and release SCSIRequest structs. Make scsi-disk and scsi-generic use them. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/scsi-bus.c')
-rw-r--r--hw/scsi-bus.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 801922b7db..cf445cebc9 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -111,3 +111,34 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
scsi_bus_legacy_add_drive(bus, dinfo, unit);
}
}
+
+SCSIRequest *scsi_req_alloc(size_t size, SCSIDevice *d, uint32_t tag, uint32_t lun)
+{
+ SCSIRequest *req;
+
+ req = qemu_mallocz(size);
+ req->bus = scsi_bus_from_device(d);
+ req->dev = d;
+ req->tag = tag;
+ req->lun = lun;
+ QTAILQ_INSERT_TAIL(&d->requests, req, next);
+ return req;
+}
+
+SCSIRequest *scsi_req_find(SCSIDevice *d, uint32_t tag)
+{
+ SCSIRequest *req;
+
+ QTAILQ_FOREACH(req, &d->requests, next) {
+ if (req->tag == tag) {
+ return req;
+ }
+ }
+ return NULL;
+}
+
+void scsi_req_free(SCSIRequest *req)
+{
+ QTAILQ_REMOVE(&req->dev->requests, req, next);
+ qemu_free(req);
+}