[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 4/5] scsi: Fix transfer length for READ POSITION com
From: |
Christian Borntraeger |
Subject: |
[Qemu-devel] [PATCH 4/5] scsi: Fix transfer length for READ POSITION commands. |
Date: |
Thu, 14 Jun 2012 15:55:28 +0200 |
From: Christian Hoff <address@hidden>
The transfer length depends on the specific service action
code, as defined in the SCSI stream commands spec section 7.7.
Up to now only the extended form was supported.
Signed-off-by: Christian Hoff <address@hidden>
Signed-off-by: Christian Borntraeger <address@hidden>
---
hw/scsi-bus.c | 16 +++++++++++++++-
hw/scsi-defs.h | 8 ++++++++
2 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index a93d3da..9854321 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -839,7 +839,21 @@ static int scsi_req_stream_length(SCSICommand *cmd,
SCSIDevice *dev, uint8_t *bu
cmd->xfer = buf[13] | (buf[12] << 8);
break;
case READ_POSITION:
- cmd->xfer = buf[8] | (buf[7] << 8);
+ switch (buf[1] & 0x1f) /* operation code */ {
+ case SHORT_FORM_BLOCK_ID:
+ case SHORT_FORM_VENDOR_SPECIFIC:
+ cmd->xfer = 20;
+ break;
+ case LONG_FORM:
+ cmd->xfer = 32;
+ break;
+ case EXTENDED_FORM:
+ cmd->xfer = buf[8] | (buf[7] << 8);
+ break;
+ default:
+ return -1;
+ }
+
break;
case FORMAT_UNIT:
cmd->xfer = buf[4] | (buf[3] << 8);
diff --git a/hw/scsi-defs.h b/hw/scsi-defs.h
index 2c40855..57d0866 100644
--- a/hw/scsi-defs.h
+++ b/hw/scsi-defs.h
@@ -144,6 +144,14 @@
#define SAI_READ_CAPACITY_16 0x10
/*
+ * READ POSITION service action codes
+ */
+#define SHORT_FORM_BLOCK_ID 0x00
+#define SHORT_FORM_VENDOR_SPECIFIC 0x01
+#define LONG_FORM 0x06
+#define EXTENDED_FORM 0x08
+
+/*
* SAM Status codes
*/
--
1.7.0.4
- [Qemu-devel] [PATCH 0/5] scsi related fixes, Christian Borntraeger, 2012/06/14
- [Qemu-devel] [PATCH 3/5] scsi: Add basic support for SCSI media changer commands., Christian Borntraeger, 2012/06/14
- [Qemu-devel] [PATCH 4/5] scsi: Fix transfer length for READ POSITION commands.,
Christian Borntraeger <=
- [Qemu-devel] [PATCH 1/5] scsi: Fix data length == SCSI_SENSE_BUF_SIZE, Christian Borntraeger, 2012/06/14
- [Qemu-devel] [PATCH 5/5] scsi: Ensure command and transfer lengths are set for all SCSI stream commands., Christian Borntraeger, 2012/06/14
- [Qemu-devel] [PATCH 2/5] scsi: Fix LOAD_UNLOAD, Christian Borntraeger, 2012/06/14
- Re: [Qemu-devel] [PATCH 0/5] scsi related fixes, Paolo Bonzini, 2012/06/14