scsi: push lun field to SCSIDevice
This will let SCSIBus detect requests sent to an invalid LUN, and handle them itself. However, there will be still support for only one LUN per target Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
2599aece1b
commit
87dcd1b2c2
@ -16,6 +16,7 @@ static struct BusInfo scsi_bus_info = {
|
|||||||
.get_fw_dev_path = scsibus_get_fw_dev_path,
|
.get_fw_dev_path = scsibus_get_fw_dev_path,
|
||||||
.props = (Property[]) {
|
.props = (Property[]) {
|
||||||
DEFINE_PROP_UINT32("scsi-id", SCSIDevice, id, -1),
|
DEFINE_PROP_UINT32("scsi-id", SCSIDevice, id, -1),
|
||||||
|
DEFINE_PROP_UINT32("lun", SCSIDevice, lun, 0),
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -60,7 +60,6 @@ struct SCSIGenericState
|
|||||||
{
|
{
|
||||||
SCSIDevice qdev;
|
SCSIDevice qdev;
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
int lun;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void scsi_free_request(SCSIRequest *req)
|
static void scsi_free_request(SCSIRequest *req)
|
||||||
@ -292,7 +291,7 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *cmd)
|
|||||||
SCSIGenericReq *r = DO_UPCAST(SCSIGenericReq, req, req);
|
SCSIGenericReq *r = DO_UPCAST(SCSIGenericReq, req, req);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (cmd[0] != REQUEST_SENSE && req->lun != s->lun) {
|
if (cmd[0] != REQUEST_SENSE && req->lun != s->qdev.lun) {
|
||||||
DPRINTF("Unimplemented LUN %d\n", req->lun);
|
DPRINTF("Unimplemented LUN %d\n", req->lun);
|
||||||
scsi_req_build_sense(&r->req, SENSE_CODE(LUN_NOT_SUPPORTED));
|
scsi_req_build_sense(&r->req, SENSE_CODE(LUN_NOT_SUPPORTED));
|
||||||
scsi_req_complete(&r->req, CHECK_CONDITION);
|
scsi_req_complete(&r->req, CHECK_CONDITION);
|
||||||
@ -466,8 +465,6 @@ static int scsi_generic_initfn(SCSIDevice *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* define device state */
|
/* define device state */
|
||||||
s->lun = scsiid.lun;
|
|
||||||
DPRINTF("LUN %d\n", s->lun);
|
|
||||||
s->qdev.type = scsiid.scsi_type;
|
s->qdev.type = scsiid.scsi_type;
|
||||||
DPRINTF("device type %d\n", s->qdev.type);
|
DPRINTF("device type %d\n", s->qdev.type);
|
||||||
if (s->qdev.type == TYPE_TAPE) {
|
if (s->qdev.type == TYPE_TAPE) {
|
||||||
|
@ -65,6 +65,7 @@ struct SCSIDevice
|
|||||||
uint8_t sense[SCSI_SENSE_BUF_SIZE];
|
uint8_t sense[SCSI_SENSE_BUF_SIZE];
|
||||||
uint32_t sense_len;
|
uint32_t sense_len;
|
||||||
QTAILQ_HEAD(, SCSIRequest) requests;
|
QTAILQ_HEAD(, SCSIRequest) requests;
|
||||||
|
uint32_t lun;
|
||||||
int blocksize;
|
int blocksize;
|
||||||
int type;
|
int type;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user