On 10/29/2014 08:53 AM, Hannes Reinecke wrote: > All scsi functions take a scsi device as argument, which has > a LUN assigned to it. So we can get rid of specifying the 'lun' > as separate argument.
... except if you are sending a command to a non-existent LUN, in which case scsi_req_new detects this and redirects to a special SCSIReqOps instance: ... else if (lun != d->lun || buf[0] == REPORT_LUNS || (buf[0] == REQUEST_SENSE && d->sense_len)) { ops = &reqops_target_command; } else { ops = NULL; } Yes, it's ugly. If you have a better idea, I'm all ears. Passing a NULL SCSIDevice is hard though. Paolo > Signed-off-by: Hannes Reinecke <h...@suse.de> > --- > hw/scsi/esp.c | 2 +- > hw/scsi/lsi53c895a.c | 3 +-- > hw/scsi/megasas.c | 44 +++++++++++++++++------------------ > hw/scsi/scsi-bus.c | 62 > +++++++++++++++++++++++--------------------------- > hw/scsi/scsi-disk.c | 13 +++++------ > hw/scsi/scsi-generic.c | 4 ++-- > hw/scsi/virtio-scsi.c | 1 - > hw/scsi/vmw_pvscsi.c | 2 +- > hw/usb/dev-storage.c | 2 +- > hw/usb/dev-uas.c | 1 - > include/hw/scsi/scsi.h | 7 +++--- > 11 files changed, 65 insertions(+), 76 deletions(-) > > diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c > index 5ab44d8..1123156 100644 > --- a/hw/scsi/esp.c > +++ b/hw/scsi/esp.c > @@ -129,7 +129,7 @@ static void do_busid_cmd(ESPState *s, uint8_t *buf, > uint8_t busid) > trace_esp_do_busid_cmd(busid); > lun = busid & 7; > current_lun = scsi_device_find(&s->bus, 0, s->current_dev->id, lun); > - s->current_req = scsi_req_new(current_lun, 0, lun, buf, s); > + s->current_req = scsi_req_new(current_lun, 0, buf, s); > datalen = scsi_req_enqueue(s->current_req); > s->ti_size = datalen; > if (datalen != 0) { > diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c > index d9b4c7e..a185e0c 100644 > --- a/hw/scsi/lsi53c895a.c > +++ b/hw/scsi/lsi53c895a.c > @@ -783,8 +783,7 @@ static void lsi_do_command(LSIState *s) > assert(s->current == NULL); > s->current = g_malloc0(sizeof(lsi_request)); > s->current->tag = s->select_tag; > - s->current->req = scsi_req_new(dev, s->current->tag, s->current_lun, buf, > - s->current); > + s->current->req = scsi_req_new(dev, s->current->tag, buf, s->current); > > n = scsi_req_enqueue(s->current->req); > if (n) { > diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c > index eedc992..5b9e508 100644 > --- a/hw/scsi/megasas.c > +++ b/hw/scsi/megasas.c > @@ -971,14 +971,13 @@ static int megasas_dcmd_pd_list_query(MegasasState *s, > MegasasCmd *cmd) > return MFI_STAT_OK; > } > > -static int megasas_pd_get_info_submit(SCSIDevice *sdev, int lun, > - MegasasCmd *cmd) > +static int megasas_pd_get_info_submit(SCSIDevice *sdev, MegasasCmd *cmd) > { > struct mfi_pd_info *info = cmd->iov_buf; > size_t dcmd_size = sizeof(struct mfi_pd_info); > BlockConf *conf = &sdev->conf; > uint64_t pd_size; > - uint16_t sdev_id = ((sdev->id & 0xFF) >> 8) | (lun & 0xFF); > + uint16_t sdev_id = ((sdev->id & 0xFF) >> 8) | (sdev->lun & 0xFF); > uint8_t cmdbuf[6]; > SCSIRequest *req; > size_t len, resid; > @@ -990,7 +989,7 @@ static int megasas_pd_get_info_submit(SCSIDevice *sdev, > int lun, > info->inquiry_data[0] = 0x7f; /* Force PQual 0x3, PType 0x1f */ > info->vpd_page83[0] = 0x7f; > megasas_setup_inquiry(cmdbuf, 0, sizeof(info->inquiry_data)); > - req = scsi_req_new(sdev, cmd->index, lun, cmdbuf, cmd); > + req = scsi_req_new(sdev, cmd->index, cmdbuf, cmd); > if (!req) { > trace_megasas_dcmd_req_alloc_failed(cmd->index, > "PD get info std inquiry"); > @@ -999,7 +998,8 @@ static int megasas_pd_get_info_submit(SCSIDevice *sdev, > int lun, > return MFI_STAT_FLASH_ALLOC_FAIL; > } > trace_megasas_dcmd_internal_submit(cmd->index, > - "PD get info std inquiry", lun); > + "PD get info std inquiry", > + sdev->lun); > len = scsi_req_enqueue(req); > if (len > 0) { > cmd->iov_size = len; > @@ -1008,14 +1008,15 @@ static int megasas_pd_get_info_submit(SCSIDevice > *sdev, int lun, > return MFI_STAT_INVALID_STATUS; > } else if (info->inquiry_data[0] != 0x7f && info->vpd_page83[0] == 0x7f) > { > megasas_setup_inquiry(cmdbuf, 0x83, sizeof(info->vpd_page83)); > - req = scsi_req_new(sdev, cmd->index, lun, cmdbuf, cmd); > + req = scsi_req_new(sdev, cmd->index, cmdbuf, cmd); > if (!req) { > trace_megasas_dcmd_req_alloc_failed(cmd->index, > "PD get info vpd inquiry"); > return MFI_STAT_FLASH_ALLOC_FAIL; > } > trace_megasas_dcmd_internal_submit(cmd->index, > - "PD get info vpd inquiry", lun); > + "PD get info vpd inquiry", > + sdev->lun); > len = scsi_req_enqueue(req); > if (len > 0) { > cmd->iov_size = len; > @@ -1074,7 +1075,7 @@ static int megasas_dcmd_pd_get_info(MegasasState *s, > MegasasCmd *cmd) > > if (sdev) { > /* Submit inquiry */ > - retval = megasas_pd_get_info_submit(sdev, pd_id, cmd); > + retval = megasas_pd_get_info_submit(sdev, cmd); > } > > return retval; > @@ -1136,8 +1137,7 @@ static int megasas_dcmd_ld_list_query(MegasasState *s, > MegasasCmd *cmd) > return MFI_STAT_OK; > } > > -static int megasas_ld_get_info_submit(SCSIDevice *sdev, int lun, > - MegasasCmd *cmd) > +static int megasas_ld_get_info_submit(SCSIDevice *sdev, MegasasCmd *cmd) > { > struct mfi_ld_info *info = cmd->iov_buf; > size_t dcmd_size = sizeof(struct mfi_ld_info); > @@ -1145,7 +1145,7 @@ static int megasas_ld_get_info_submit(SCSIDevice *sdev, > int lun, > SCSIRequest *req; > ssize_t len, resid; > BlockConf *conf = &sdev->conf; > - uint16_t sdev_id = ((sdev->id & 0xFF) >> 8) | (lun & 0xFF); > + uint16_t sdev_id = ((sdev->id & 0xFF) >> 8) | (sdev->lun & 0xFF); > uint64_t ld_size; > > if (!cmd->iov_buf) { > @@ -1153,7 +1153,7 @@ static int megasas_ld_get_info_submit(SCSIDevice *sdev, > int lun, > memset(cmd->iov_buf, 0x0, dcmd_size); > info = cmd->iov_buf; > megasas_setup_inquiry(cdb, 0x83, sizeof(info->vpd_page83)); > - req = scsi_req_new(sdev, cmd->index, lun, cdb, cmd); > + req = scsi_req_new(sdev, cmd->index, cdb, cmd); > if (!req) { > trace_megasas_dcmd_req_alloc_failed(cmd->index, > "LD get info vpd inquiry"); > @@ -1162,7 +1162,8 @@ static int megasas_ld_get_info_submit(SCSIDevice *sdev, > int lun, > return MFI_STAT_FLASH_ALLOC_FAIL; > } > trace_megasas_dcmd_internal_submit(cmd->index, > - "LD get info vpd inquiry", lun); > + "LD get info vpd inquiry", > + sdev->lun); > len = scsi_req_enqueue(req); > if (len > 0) { > cmd->iov_size = len; > @@ -1172,7 +1173,7 @@ static int megasas_ld_get_info_submit(SCSIDevice *sdev, > int lun, > } > > info->ld_config.params.state = MFI_LD_STATE_OPTIMAL; > - info->ld_config.properties.ld.v.target_id = lun; > + info->ld_config.properties.ld.v.target_id = sdev->lun; > info->ld_config.params.stripe_size = 3; > info->ld_config.params.num_drives = 1; > info->ld_config.params.is_consistent = 1; > @@ -1217,7 +1218,7 @@ static int megasas_dcmd_ld_get_info(MegasasState *s, > MegasasCmd *cmd) > } > > if (sdev) { > - retval = megasas_ld_get_info_submit(sdev, ld_id, cmd); > + retval = megasas_ld_get_info_submit(sdev, cmd); > } > > return retval; > @@ -1509,17 +1510,16 @@ static int megasas_finish_internal_dcmd(MegasasCmd > *cmd, > { > int opcode; > int retval = MFI_STAT_OK; > - int lun = req->lun; > > opcode = le32_to_cpu(cmd->frame->dcmd.opcode); > scsi_req_unref(req); > - trace_megasas_dcmd_internal_finish(cmd->index, opcode, lun); > + trace_megasas_dcmd_internal_finish(cmd->index, opcode, req->dev->lun); > switch (opcode) { > case MFI_DCMD_PD_GET_INFO: > - retval = megasas_pd_get_info_submit(req->dev, lun, cmd); > + retval = megasas_pd_get_info_submit(req->dev, cmd); > break; > case MFI_DCMD_LD_GET_INFO: > - retval = megasas_ld_get_info_submit(req->dev, lun, cmd); > + retval = megasas_ld_get_info_submit(req->dev, cmd); > break; > default: > trace_megasas_dcmd_internal_invalid(cmd->index, opcode); > @@ -1609,8 +1609,7 @@ static int megasas_handle_scsi(MegasasState *s, > MegasasCmd *cmd, > return MFI_STAT_SCSI_DONE_WITH_ERROR; > } > > - cmd->req = scsi_req_new(sdev, cmd->index, > - cmd->frame->header.lun_id, cdb, cmd); > + cmd->req = scsi_req_new(sdev, cmd->index, cdb, cmd); > if (!cmd->req) { > trace_megasas_scsi_req_alloc_failed( > mfi_frame_desc[cmd->frame->header.frame_cmd], > @@ -1686,8 +1685,7 @@ static int megasas_handle_io(MegasasState *s, > MegasasCmd *cmd) > } > > megasas_encode_lba(cdb, lba_start, lba_count, is_write); > - cmd->req = scsi_req_new(sdev, cmd->index, > - cmd->frame->header.lun_id, cdb, cmd); > + cmd->req = scsi_req_new(sdev, cmd->index, cdb, cmd); > if (!cmd->req) { > trace_megasas_scsi_req_alloc_failed( > mfi_frame_desc[cmd->frame->header.frame_cmd], > diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c > index 64d0880..0f13b77 100644 > --- a/hw/scsi/scsi-bus.c > +++ b/hw/scsi/scsi-bus.c > @@ -72,12 +72,12 @@ int scsi_bus_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, > uint8_t *buf, > return rc; > } > > -static SCSIRequest *scsi_device_alloc_req(SCSIDevice *s, uint32_t tag, > uint32_t lun, > +static SCSIRequest *scsi_device_alloc_req(SCSIDevice *s, uint32_t tag, > uint8_t *buf, void *hba_private) > { > SCSIDeviceClass *sc = SCSI_DEVICE_GET_CLASS(s); > if (sc->alloc_req) { > - return sc->alloc_req(s, tag, lun, buf, hba_private); > + return sc->alloc_req(s, tag, buf, hba_private); > } > > return NULL; > @@ -401,8 +401,6 @@ static bool scsi_target_emulate_report_luns(SCSITargetReq > *r) > > static bool scsi_target_emulate_inquiry(SCSITargetReq *r) > { > - assert(r->req.dev->lun != r->req.lun); > - > scsi_target_alloc_buf(&r->req, SCSI_INQUIRY_LEN); > > if (r->req.cmd.buf[1] & 0x2) { > @@ -442,7 +440,7 @@ static bool scsi_target_emulate_inquiry(SCSITargetReq *r) > /* PAGE CODE == 0 */ > r->len = MIN(r->req.cmd.xfer, SCSI_INQUIRY_LEN); > memset(r->buf, 0, r->len); > - if (r->req.lun != 0) { > + if (r->req.dev->lun != 0) { > r->buf[0] = TYPE_NO_LUN; > } else { > r->buf[0] = TYPE_NOT_PRESENT | TYPE_INACTIVE; > @@ -549,7 +547,7 @@ static const struct SCSIReqOps reqops_target_command = { > > > SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d, > - uint32_t tag, uint32_t lun, void *hba_private) > + uint32_t tag, void *hba_private) > { > SCSIRequest *req; > SCSIBus *bus = scsi_bus_from_device(d); > @@ -563,18 +561,17 @@ SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, > SCSIDevice *d, > req->bus = bus; > req->dev = d; > req->tag = tag; > - req->lun = lun; > req->hba_private = hba_private; > req->status = -1; > req->ops = reqops; > object_ref(OBJECT(d)); > object_ref(OBJECT(qbus->parent)); > notifier_list_init(&req->cancel_notifiers); > - trace_scsi_req_alloc(req->dev->id, req->lun, req->tag); > + trace_scsi_req_alloc(req->dev->id, req->dev->lun, req->tag); > return req; > } > > -SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun, > +SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, > uint8_t *buf, void *hba_private) > { > SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, d->qdev.parent_bus); > @@ -597,8 +594,7 @@ SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, > uint32_t lun, > */ > !(buf[0] == REQUEST_SENSE && d->sense_is_ua))) { > ops = &reqops_unit_attention; > - } else if (lun != d->lun || > - buf[0] == REPORT_LUNS || > + } else if (buf[0] == REPORT_LUNS || > (buf[0] == REQUEST_SENSE && d->sense_len)) { > ops = &reqops_target_command; > } else { > @@ -612,23 +608,22 @@ SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, > uint32_t lun, > } > > if (ret != 0) { > - trace_scsi_req_parse_bad(d->id, lun, tag, buf[0]); > - req = scsi_req_alloc(&reqops_invalid_opcode, d, tag, lun, > hba_private); > + trace_scsi_req_parse_bad(d->id, d->lun, tag, buf[0]); > + req = scsi_req_alloc(&reqops_invalid_opcode, d, tag, hba_private); > } else { > assert(cmd.len != 0); > - trace_scsi_req_parsed(d->id, lun, tag, buf[0], > + trace_scsi_req_parsed(d->id, d->lun, tag, buf[0], > cmd.mode, cmd.xfer); > if (cmd.lba != -1) { > - trace_scsi_req_parsed_lba(d->id, lun, tag, buf[0], > - cmd.lba); > + trace_scsi_req_parsed_lba(d->id, d->lun, tag, buf[0], cmd.lba); > } > > if (cmd.xfer > INT32_MAX) { > - req = scsi_req_alloc(&reqops_invalid_field, d, tag, lun, > hba_private); > + req = scsi_req_alloc(&reqops_invalid_field, d, tag, hba_private); > } else if (ops) { > - req = scsi_req_alloc(ops, d, tag, lun, hba_private); > + req = scsi_req_alloc(ops, d, tag, hba_private); > } else { > - req = scsi_device_alloc_req(d, tag, lun, buf, hba_private); > + req = scsi_device_alloc_req(d, tag, buf, hba_private); > } > } > > @@ -637,16 +632,16 @@ SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, > uint32_t lun, > > switch (buf[0]) { > case INQUIRY: > - trace_scsi_inquiry(d->id, lun, tag, cmd.buf[1], cmd.buf[2]); > + trace_scsi_inquiry(d->id, d->lun, tag, cmd.buf[1], cmd.buf[2]); > break; > case TEST_UNIT_READY: > - trace_scsi_test_unit_ready(d->id, lun, tag); > + trace_scsi_test_unit_ready(d->id, d->lun, tag); > break; > case REPORT_LUNS: > - trace_scsi_report_luns(d->id, lun, tag); > + trace_scsi_report_luns(d->id, d->lun, tag); > break; > case REQUEST_SENSE: > - trace_scsi_request_sense(d->id, lun, tag); > + trace_scsi_request_sense(d->id, d->lun, tag); > break; > default: > break; > @@ -734,7 +729,7 @@ int scsi_device_get_sense(SCSIDevice *dev, uint8_t *buf, > int len, bool fixed) > > void scsi_req_build_sense(SCSIRequest *req, SCSISense sense) > { > - trace_scsi_req_build_sense(req->dev->id, req->lun, req->tag, > + trace_scsi_req_build_sense(req->dev->id, req->dev->lun, req->tag, > sense.key, sense.asc, sense.ascq); > memset(req->sense, 0, 18); > req->sense[0] = 0x70; > @@ -772,7 +767,7 @@ int32_t scsi_req_enqueue(SCSIRequest *req) > > static void scsi_req_dequeue(SCSIRequest *req) > { > - trace_scsi_req_dequeue(req->dev->id, req->lun, req->tag); > + trace_scsi_req_dequeue(req->dev->id, req->dev->lun, req->tag); > req->retry = false; > if (req->enqueued) { > QTAILQ_REMOVE(&req->dev->requests, req, next); > @@ -1622,10 +1617,10 @@ void scsi_req_unref(SCSIRequest *req) > void scsi_req_continue(SCSIRequest *req) > { > if (req->io_canceled) { > - trace_scsi_req_continue_canceled(req->dev->id, req->lun, req->tag); > + trace_scsi_req_continue_canceled(req->dev->id, req->dev->lun, > req->tag); > return; > } > - trace_scsi_req_continue(req->dev->id, req->lun, req->tag); > + trace_scsi_req_continue(req->dev->id, req->dev->lun, req->tag); > if (req->cmd.mode == SCSI_XFER_TO_DEV) { > req->ops->write_data(req); > } else { > @@ -1640,10 +1635,11 @@ void scsi_req_data(SCSIRequest *req, int len) > { > uint8_t *buf; > if (req->io_canceled) { > - trace_scsi_req_data_canceled(req->dev->id, req->lun, req->tag, len); > + trace_scsi_req_data_canceled(req->dev->id, req->dev->lun, > + req->tag, len); > return; > } > - trace_scsi_req_data(req->dev->id, req->lun, req->tag, len); > + trace_scsi_req_data(req->dev->id, req->dev->lun, req->tag, len); > assert(req->cmd.mode != SCSI_XFER_NONE); > if (!req->sg) { > req->resid -= len; > @@ -1746,7 +1742,7 @@ void scsi_req_cancel_complete(SCSIRequest *req) > * */ > void scsi_req_cancel_async(SCSIRequest *req, Notifier *notifier) > { > - trace_scsi_req_cancel(req->dev->id, req->lun, req->tag); > + trace_scsi_req_cancel(req->dev->id, req->dev->lun, req->tag); > if (notifier) { > notifier_list_add(&req->cancel_notifiers, notifier); > } > @@ -1763,7 +1759,7 @@ void scsi_req_cancel_async(SCSIRequest *req, Notifier > *notifier) > > void scsi_req_cancel(SCSIRequest *req) > { > - trace_scsi_req_cancel(req->dev->id, req->lun, req->tag); > + trace_scsi_req_cancel(req->dev->id, req->dev->lun, req->tag); > if (!req->enqueued) { > return; > } > @@ -1895,7 +1891,7 @@ static void put_scsi_requests(QEMUFile *f, void *pv, > size_t size) > qemu_put_sbyte(f, req->retry ? 1 : 2); > qemu_put_buffer(f, req->cmd.buf, sizeof(req->cmd.buf)); > qemu_put_be32s(f, &req->tag); > - qemu_put_be32s(f, &req->lun); > + qemu_put_be32s(f, &req->dev->lun); > if (bus->info->save_request) { > bus->info->save_request(f, req); > } > @@ -1921,7 +1917,7 @@ static int get_scsi_requests(QEMUFile *f, void *pv, > size_t size) > qemu_get_buffer(f, buf, sizeof(buf)); > qemu_get_be32s(f, &tag); > qemu_get_be32s(f, &lun); > - req = scsi_req_new(s, tag, lun, buf, NULL); > + req = scsi_req_new(s, tag, buf, NULL); > req->retry = (sbyte == 1); > if (bus->info->load_request) { > req->hba_private = bus->info->load_request(f, req); > diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c > index 30e3789..dec669e 100644 > --- a/hw/scsi/scsi-disk.c > +++ b/hw/scsi/scsi-disk.c > @@ -2374,7 +2374,7 @@ static const SCSIReqOps *const > scsi_disk_reqops_dispatch[256] = { > [WRITE_VERIFY_16] = &scsi_disk_dma_reqops, > }; > > -static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t > lun, > +static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, > uint8_t *buf, void *hba_private) > { > SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d); > @@ -2387,10 +2387,10 @@ static SCSIRequest *scsi_new_request(SCSIDevice *d, > uint32_t tag, uint32_t lun, > if (!ops) { > ops = &scsi_disk_emulate_reqops; > } > - req = scsi_req_alloc(ops, &s->qdev, tag, lun, hba_private); > + req = scsi_req_alloc(ops, &s->qdev, tag, hba_private); > > #ifdef DEBUG_SCSI > - DPRINTF("Command: lun=%d tag=0x%x data=0x%02x", lun, tag, buf[0]); > + DPRINTF("Command: lun=%d tag=0x%x data=0x%02x", d->lun, tag, buf[0]); > { > int i; > for (i = 1; i < scsi_cdb_length(buf); i++) { > @@ -2539,16 +2539,15 @@ static bool scsi_block_is_passthrough(SCSIDiskState > *s, uint8_t *buf) > > > static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag, > - uint32_t lun, uint8_t *buf, > - void *hba_private) > + uint8_t *buf, void *hba_private) > { > SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d); > > if (scsi_block_is_passthrough(s, buf)) { > - return scsi_req_alloc(&scsi_generic_req_ops, &s->qdev, tag, lun, > + return scsi_req_alloc(&scsi_generic_req_ops, &s->qdev, tag, > hba_private); > } else { > - return scsi_req_alloc(&scsi_disk_dma_reqops, &s->qdev, tag, lun, > + return scsi_req_alloc(&scsi_disk_dma_reqops, &s->qdev, tag, > hba_private); > } > } > diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c > index 84a1d5b..837f670 100644 > --- a/hw/scsi/scsi-generic.c > +++ b/hw/scsi/scsi-generic.c > @@ -449,12 +449,12 @@ const SCSIReqOps scsi_generic_req_ops = { > .save_request = scsi_generic_save_request, > }; > > -static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t > lun, > +static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, > uint8_t *buf, void *hba_private) > { > SCSIRequest *req; > > - req = scsi_req_alloc(&scsi_generic_req_ops, d, tag, lun, hba_private); > + req = scsi_req_alloc(&scsi_generic_req_ops, d, tag, hba_private); > return req; > } > > diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c > index 8547ea0..dd71edc 100644 > --- a/hw/scsi/virtio-scsi.c > +++ b/hw/scsi/virtio-scsi.c > @@ -528,7 +528,6 @@ bool virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, > VirtIOSCSIReq *req) > aio_context_release(s->ctx); > } > req->sreq = scsi_req_new(d, req->req.cmd.tag, > - virtio_scsi_get_lun(req->req.cmd.lun), > req->req.cdb, req); > > if (req->sreq->cmd.mode != SCSI_XFER_NONE > diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c > index d3a92fb..873c830 100644 > --- a/hw/scsi/vmw_pvscsi.c > +++ b/hw/scsi/vmw_pvscsi.c > @@ -652,7 +652,7 @@ pvscsi_process_request_descriptor(PVSCSIState *s, > r->sg.elemAddr = descr->dataAddr; > } > > - r->sreq = scsi_req_new(d, descr->context, r->lun, descr->cdb, r); > + r->sreq = scsi_req_new(d, descr->context, descr->cdb, r); > if (r->sreq->cmd.mode == SCSI_XFER_FROM_DEV && > (descr->flags & PVSCSI_FLAG_CMD_DIR_TODEVICE)) { > r->cmp.hostStatus = BTSTAT_BADMSG; > diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c > index 5bfc72c..c2e9d50 100644 > --- a/hw/usb/dev-storage.c > +++ b/hw/usb/dev-storage.c > @@ -439,7 +439,7 @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket > *p) > tag, cbw.flags, cbw.cmd_len, s->data_len); > assert(le32_to_cpu(s->csw.residue) == 0); > s->scsi_len = 0; > - s->req = scsi_req_new(scsi_dev, tag, cbw.lun, cbw.cmd, NULL); > + s->req = scsi_req_new(scsi_dev, tag, cbw.cmd, NULL); > #ifdef DEBUG_MSD > scsi_req_print(s->req); > #endif > diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c > index 04fc515..dcb3773 100644 > --- a/hw/usb/dev-uas.c > +++ b/hw/usb/dev-uas.c > @@ -714,7 +714,6 @@ static void usb_uas_command(UASDevice *uas, uas_iu *iu) > } > > req->req = scsi_req_new(req->dev, req->tag, > - usb_uas_get_lun(req->lun), > iu->command.cdb, req); > if (uas->requestlog) { > scsi_req_print(req->req); > diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h > index 4e9bbd1..afb3f5d 100644 > --- a/include/hw/scsi/scsi.h > +++ b/include/hw/scsi/scsi.h > @@ -49,7 +49,6 @@ struct SCSIRequest { > const SCSIReqOps *ops; > uint32_t refcount; > uint32_t tag; > - uint32_t lun; > uint32_t status; > void *hba_private; > size_t resid; > @@ -87,7 +86,7 @@ typedef struct SCSIDeviceClass { > void (*unrealize)(SCSIDevice *dev, Error **errp); > int (*parse_cdb)(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf, > void *hba_private); > - SCSIRequest *(*alloc_req)(SCSIDevice *s, uint32_t tag, uint32_t lun, > + SCSIRequest *(*alloc_req)(SCSIDevice *s, uint32_t tag, > uint8_t *buf, void *hba_private); > void (*unit_attention_reported)(SCSIDevice *s); > } SCSIDeviceClass; > @@ -247,8 +246,8 @@ int scsi_build_sense(uint8_t *in_buf, int in_len, > uint8_t *buf, int len, bool fixed); > > SCSIRequest *scsi_req_alloc(const 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, > + uint32_t tag, void *hba_private); > +SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, > uint8_t *buf, void *hba_private); > int32_t scsi_req_enqueue(SCSIRequest *req); > void scsi_req_free(SCSIRequest *req); >