Revision 89b08ae1 hw/scsi-disk.c

b/hw/scsi-disk.c
71 71
    QEMUBH *bh;
72 72
};
73 73

  
74
static SCSIDiskReq *scsi_new_request(SCSIDevice *d, uint32_t tag)
74
static SCSIDiskReq *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun)
75 75
{
76
    SCSIRequest *req;
76 77
    SCSIDiskReq *r;
77 78

  
78
    r = qemu_mallocz(sizeof(SCSIDiskReq));
79
    req = scsi_req_alloc(sizeof(SCSIDiskReq), d, tag, lun);
80
    r = DO_UPCAST(SCSIDiskReq, req, req);
79 81
    r->iov.iov_base = qemu_memalign(512, SCSI_DMA_BUF_SIZE);
80
    r->req.bus = scsi_bus_from_device(d);
81
    r->req.dev = d;
82
    r->req.tag = tag;
83

  
84
    QTAILQ_INSERT_TAIL(&d->requests, &r->req, next);
85 82
    return r;
86 83
}
87 84

  
88 85
static void scsi_remove_request(SCSIDiskReq *r)
89 86
{
90 87
    qemu_free(r->iov.iov_base);
91
    QTAILQ_REMOVE(&r->req.dev->requests, &r->req, next);
92
    qemu_free(r);
88
    scsi_req_free(&r->req);
93 89
}
94 90

  
95 91
static SCSIDiskReq *scsi_find_request(SCSIDiskState *s, uint32_t tag)
96 92
{
97
    SCSIRequest *req;
98

  
99
    QTAILQ_FOREACH(req, &s->qdev.requests, next) {
100
        if (req->tag == tag) {
101
            return DO_UPCAST(SCSIDiskReq, req, req);
102
        }
103
    }
104
    return NULL;
93
    return DO_UPCAST(SCSIDiskReq, req, scsi_req_find(&s->qdev, tag));
105 94
}
106 95

  
107 96
/* Helper function for command completion.  */
......
113 102
            r->req.tag, status, sense);
114 103
    s->sense = sense;
115 104
    tag = r->req.tag;
116
    scsi_remove_request(r);
117 105
    r->req.bus->complete(r->req.bus, SCSI_REASON_DONE, tag, status);
106
    scsi_remove_request(r);
118 107
}
119 108

  
120 109
/* Cancel a pending data transfer.  */
......
349 338
    }
350 339
    /* ??? Tags are not unique for different luns.  We only implement a
351 340
       single lun, so this should not matter.  */
352
    r = scsi_new_request(d, tag);
341
    r = scsi_new_request(d, tag, lun);
353 342
    outbuf = (uint8_t *)r->iov.iov_base;
354 343
    is_write = 0;
355 344
    DPRINTF("Command: lun=%d tag=0x%x data=0x%02x", lun, tag, buf[0]);

Also available in: Unified diff