scsi-block, scsi-generic: implement parse_cdb
The callback lets the bus provide the direction and transfer count for passthrough commands, enabling passthrough of vendor-specific commands. Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
592c3b289f
commit
3e7e180ab3
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
static char *scsibus_get_dev_path(DeviceState *dev);
|
static char *scsibus_get_dev_path(DeviceState *dev);
|
||||||
static char *scsibus_get_fw_dev_path(DeviceState *dev);
|
static char *scsibus_get_fw_dev_path(DeviceState *dev);
|
||||||
static int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf);
|
|
||||||
static void scsi_req_dequeue(SCSIRequest *req);
|
static void scsi_req_dequeue(SCSIRequest *req);
|
||||||
static uint8_t *scsi_target_alloc_buf(SCSIRequest *req, size_t len);
|
static uint8_t *scsi_target_alloc_buf(SCSIRequest *req, size_t len);
|
||||||
static void scsi_target_free_buf(SCSIRequest *req);
|
static void scsi_target_free_buf(SCSIRequest *req);
|
||||||
|
@ -1210,7 +1209,7 @@ static uint64_t scsi_cmd_lba(SCSICommand *cmd)
|
||||||
return lba;
|
return lba;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf)
|
int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
|
|
@ -2564,6 +2564,19 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag,
|
||||||
hba_private);
|
hba_private);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int scsi_block_parse_cdb(SCSIDevice *d, SCSICommand *cmd,
|
||||||
|
uint8_t *buf, void *hba_private)
|
||||||
|
{
|
||||||
|
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d);
|
||||||
|
|
||||||
|
if (scsi_block_is_passthrough(s, buf)) {
|
||||||
|
return scsi_bus_parse_cdb(&s->qdev, cmd, buf, hba_private);
|
||||||
|
} else {
|
||||||
|
return scsi_req_parse_cdb(&s->qdev, cmd, buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEFINE_SCSI_DISK_PROPERTIES() \
|
#define DEFINE_SCSI_DISK_PROPERTIES() \
|
||||||
|
@ -2672,6 +2685,7 @@ static void scsi_block_class_initfn(ObjectClass *klass, void *data)
|
||||||
sc->init = scsi_block_initfn;
|
sc->init = scsi_block_initfn;
|
||||||
sc->destroy = scsi_destroy;
|
sc->destroy = scsi_destroy;
|
||||||
sc->alloc_req = scsi_block_new_request;
|
sc->alloc_req = scsi_block_new_request;
|
||||||
|
sc->parse_cdb = scsi_block_parse_cdb;
|
||||||
dc->fw_name = "disk";
|
dc->fw_name = "disk";
|
||||||
dc->desc = "SCSI block device passthrough";
|
dc->desc = "SCSI block device passthrough";
|
||||||
dc->reset = scsi_disk_reset;
|
dc->reset = scsi_disk_reset;
|
||||||
|
|
|
@ -490,6 +490,12 @@ static Property scsi_generic_properties[] = {
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int scsi_generic_parse_cdb(SCSIDevice *dev, SCSICommand *cmd,
|
||||||
|
uint8_t *buf, void *hba_private)
|
||||||
|
{
|
||||||
|
return scsi_bus_parse_cdb(dev, cmd, buf, hba_private);
|
||||||
|
}
|
||||||
|
|
||||||
static void scsi_generic_class_initfn(ObjectClass *klass, void *data)
|
static void scsi_generic_class_initfn(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
@ -498,6 +504,7 @@ static void scsi_generic_class_initfn(ObjectClass *klass, void *data)
|
||||||
sc->init = scsi_generic_initfn;
|
sc->init = scsi_generic_initfn;
|
||||||
sc->destroy = scsi_destroy;
|
sc->destroy = scsi_destroy;
|
||||||
sc->alloc_req = scsi_new_request;
|
sc->alloc_req = scsi_new_request;
|
||||||
|
sc->parse_cdb = scsi_generic_parse_cdb;
|
||||||
dc->fw_name = "disk";
|
dc->fw_name = "disk";
|
||||||
dc->desc = "pass through generic scsi device (/dev/sg*)";
|
dc->desc = "pass through generic scsi device (/dev/sg*)";
|
||||||
dc->reset = scsi_generic_reset;
|
dc->reset = scsi_generic_reset;
|
||||||
|
|
|
@ -250,6 +250,7 @@ void scsi_req_unref(SCSIRequest *req);
|
||||||
|
|
||||||
int scsi_bus_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf,
|
int scsi_bus_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf,
|
||||||
void *hba_private);
|
void *hba_private);
|
||||||
|
int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf);
|
||||||
void scsi_req_build_sense(SCSIRequest *req, SCSISense sense);
|
void scsi_req_build_sense(SCSIRequest *req, SCSISense sense);
|
||||||
void scsi_req_print(SCSIRequest *req);
|
void scsi_req_print(SCSIRequest *req);
|
||||||
void scsi_req_continue(SCSIRequest *req);
|
void scsi_req_continue(SCSIRequest *req);
|
||||||
|
|
Loading…
Reference in New Issue