[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 03/20] scsi-block: extract scsi_block_is_passthrough
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 03/20] scsi-block: extract scsi_block_is_passthrough |
Date: |
Tue, 19 Aug 2014 12:42:46 +0200 |
This will be used for both scsi_block_new_request and the scsi-block
implementation of parse_cdb.
Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/scsi/scsi-disk.c | 38 ++++++++++++++++++++++++++------------
1 file changed, 26 insertions(+), 12 deletions(-)
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index d47ecd6..81b7276 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2501,12 +2501,8 @@ static int scsi_block_initfn(SCSIDevice *dev)
return scsi_initfn(&s->qdev);
}
-static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag,
- uint32_t lun, uint8_t *buf,
- void *hba_private)
+static bool scsi_block_is_passthrough(SCSIDiskState *s, uint8_t *buf)
{
- SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, d);
-
switch (buf[0]) {
case READ_6:
case READ_10:
@@ -2523,9 +2519,9 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d,
uint32_t tag,
case WRITE_VERIFY_12:
case WRITE_VERIFY_16:
/* If we are not using O_DIRECT, we might read stale data from the
- * host cache if writes were made using other commands than these
- * ones (such as WRITE SAME or EXTENDED COPY, etc.). So, without
- * O_DIRECT everything must go through SG_IO.
+ * host cache if writes were made using other commands than these
+ * ones (such as WRITE SAME or EXTENDED COPY, etc.). So, without
+ * O_DIRECT everything must go through SG_IO.
*/
if (!(bdrv_get_flags(s->qdev.conf.bs) & BDRV_O_NOCACHE)) {
break;
@@ -2542,13 +2538,31 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice
*d, uint32_t tag,
* just make scsi-block operate the same as scsi-generic for them.
*/
if (s->qdev.type != TYPE_ROM) {
- return scsi_req_alloc(&scsi_disk_dma_reqops, &s->qdev, tag, lun,
- hba_private);
+ return false;
}
+ break;
+
+ default:
+ break;
}
- return scsi_req_alloc(&scsi_generic_req_ops, &s->qdev, tag, lun,
- hba_private);
+ 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,
+ hba_private);
+ }
}
#endif
--
1.8.3.1
- [Qemu-devel] [PULL 00/20] SCSI and memory changes for 2014-08-18, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 01/20] scsi-bus: prepare scsi_req_new for introduction of parse_cdb, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 02/20] scsi-bus: introduce parse_cdb in SCSIDeviceClass and SCSIBusInfo, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 03/20] scsi-block: extract scsi_block_is_passthrough,
Paolo Bonzini <=
- [Qemu-devel] [PULL 04/20] scsi-block, scsi-generic: implement parse_cdb, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 05/20] virtio-scsi: implement parse_cdb, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 06/20] qom: object: delete properties before calling instance_finalize, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 07/20] qom: object: move unparenting to the child property's release callback, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 08/20] sysbus: remove unused function sysbus_del_io, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 09/20] vga: do not dynamically allocate chain4_alias, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 10/20] nic: do not destroy memory regions in cleanup functions, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 11/20] ioport: split deletion and destruction, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 12/20] memory: convert memory_region_destroy to object_unparent, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 13/20] memory: remove memory_region_destroy, Paolo Bonzini, 2014/08/19