scsi-block: extract scsi_block_is_passthrough
This will be used for both scsi_block_new_request and the scsi-block implementation of parse_cdb. Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
ff34c32ccc
commit
592c3b289f
@ -2501,12 +2501,8 @@ static int scsi_block_initfn(SCSIDevice *dev)
|
|||||||
return scsi_initfn(&s->qdev);
|
return scsi_initfn(&s->qdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag,
|
static bool scsi_block_is_passthrough(SCSIDiskState *s, uint8_t *buf)
|
||||||
uint32_t lun, uint8_t *buf,
|
|
||||||
void *hba_private)
|
|
||||||
{
|
{
|
||||||
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d);
|
|
||||||
|
|
||||||
switch (buf[0]) {
|
switch (buf[0]) {
|
||||||
case READ_6:
|
case READ_6:
|
||||||
case READ_10:
|
case READ_10:
|
||||||
@ -2542,14 +2538,32 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag,
|
|||||||
* just make scsi-block operate the same as scsi-generic for them.
|
* just make scsi-block operate the same as scsi-generic for them.
|
||||||
*/
|
*/
|
||||||
if (s->qdev.type != TYPE_ROM) {
|
if (s->qdev.type != TYPE_ROM) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag,
|
||||||
|
uint32_t lun, 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,
|
||||||
|
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, lun,
|
||||||
hba_private);
|
hba_private);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return scsi_req_alloc(&scsi_generic_req_ops, &s->qdev, tag, lun,
|
|
||||||
hba_private);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEFINE_SCSI_DISK_PROPERTIES() \
|
#define DEFINE_SCSI_DISK_PROPERTIES() \
|
||||||
|
Loading…
Reference in New Issue
Block a user