* [Qemu-devel] [FOR 0.12 PATCH] scsi-disk: Inquiry with allocation length of CDB < 36 (v3)
@ 2009-12-12 19:24 Artyom Tarasenko
2009-12-13 8:37 ` [Qemu-devel] " Blue Swirl
0 siblings, 1 reply; 3+ messages in thread
From: Artyom Tarasenko @ 2009-12-12 19:24 UTC (permalink / raw)
To: qemu-devel; +Cc: Blue Swirl, Artyom Tarasenko
According to the SCSI-2 specification,
http://ldkelley.com/SCSI2/SCSI2/SCSI2/SCSI2-08.html#8.2.5 ,
"if the allocation length of the command descriptor block (CDB) is too
small to transfer all of the parameters, the additional length shall
not be adjusted to reflect the truncation."
The 36 mandatory bytes of response are written to outbuf, and then
only the length requested in CDB is transferred.
---
Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
---
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 2e7a57b..495ba35 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -5,6 +5,12 @@
* Based on code by Fabrice Bellard
*
* Written by Paul Brook
+ * Modifications:
+ * 2009-Dec-12 Artyom Tarasenko : implemented stamdard inquiry for the case
+ * when the allocation length of CDB is smaller
+ * than 36.
+ * 2009-Oct-13 Artyom Tarasenko : implemented the block descriptor in the
+ * MODE SENSE response.
*
* This code is licenced under the LGPL.
*
@@ -406,11 +412,6 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf)
return -1;
}
- if (req->cmd.xfer < 36) {
- BADF("Error: Inquiry (STANDARD) buffer size %zd "
- "is less than 36 (TODO: only 5 required)\n", req->cmd.xfer);
- }
-
buflen = req->cmd.xfer;
if (buflen > SCSI_MAX_INQUIRY_LEN)
buflen = SCSI_MAX_INQUIRY_LEN;
@@ -436,7 +437,15 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf)
Some later commands are also implemented. */
outbuf[2] = 3;
outbuf[3] = 2; /* Format 2 */
- outbuf[4] = buflen - 5; /* Additional Length = (Len - 1) - 4 */
+
+ if (len > 36) {
+ outbuf[4] = len - 5; /* Additional Length = (Len - 1) - 4 */
+ } else {
+ /* If the allocation length of CDB is too small,
+ the additional length is not adjusted */
+ outbuf[4] = 36 - 5;
+ }
+
/* Sync data transfer and TCQ. */
outbuf[7] = 0x10 | (req->bus->tcq ? 0x02 : 0);
return buflen;
^ permalink raw reply related [flat|nested] 3+ messages in thread* [Qemu-devel] Re: [FOR 0.12 PATCH] scsi-disk: Inquiry with allocation length of CDB < 36 (v3)
2009-12-12 19:24 [Qemu-devel] [FOR 0.12 PATCH] scsi-disk: Inquiry with allocation length of CDB < 36 (v3) Artyom Tarasenko
@ 2009-12-13 8:37 ` Blue Swirl
2009-12-13 10:13 ` Artyom Tarasenko
0 siblings, 1 reply; 3+ messages in thread
From: Blue Swirl @ 2009-12-13 8:37 UTC (permalink / raw)
To: Artyom Tarasenko, qemu-devel
On Sat, Dec 12, 2009 at 7:24 PM, Artyom Tarasenko
<atar4qemu@googlemail.com> wrote:
> According to the SCSI-2 specification,
> http://ldkelley.com/SCSI2/SCSI2/SCSI2/SCSI2-08.html#8.2.5 ,
> "if the allocation length of the command descriptor block (CDB) is too
> small to transfer all of the parameters, the additional length shall
> not be adjusted to reflect the truncation."
> The 36 mandatory bytes of response are written to outbuf, and then
> only the length requested in CDB is transferred.
> ---
> Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
Please leave out "---" between body and SoB in the future, now the SoB
is automagically dropped by git-am.
The patch applies cleanly, but:
CC scsi-disk.o
/src/qemu/hw/scsi-disk.c: In function 'scsi_disk_emulate_inquiry':
/src/qemu/hw/scsi-disk.c:441: error: 'len' undeclared (first use in
this function)
/src/qemu/hw/scsi-disk.c:441: error: (Each undeclared identifier is
reported only once
/src/qemu/hw/scsi-disk.c:441: error: for each function it appears in.)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] Re: [FOR 0.12 PATCH] scsi-disk: Inquiry with allocation length of CDB < 36 (v3)
2009-12-13 8:37 ` [Qemu-devel] " Blue Swirl
@ 2009-12-13 10:13 ` Artyom Tarasenko
0 siblings, 0 replies; 3+ messages in thread
From: Artyom Tarasenko @ 2009-12-13 10:13 UTC (permalink / raw)
To: Blue Swirl; +Cc: qemu-devel
2009/12/13 Blue Swirl <blauwirbel@gmail.com>:
> On Sat, Dec 12, 2009 at 7:24 PM, Artyom Tarasenko
> <atar4qemu@googlemail.com> wrote:
>> According to the SCSI-2 specification,
>> http://ldkelley.com/SCSI2/SCSI2/SCSI2/SCSI2-08.html#8.2.5 ,
>> "if the allocation length of the command descriptor block (CDB) is too
>> small to transfer all of the parameters, the additional length shall
>> not be adjusted to reflect the truncation."
>> The 36 mandatory bytes of response are written to outbuf, and then
>> only the length requested in CDB is transferred.
>> ---
>> Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
>
> Please leave out "---" between body and SoB in the future, now the SoB
> is automagically dropped by git-am.
Thanks, still learning how to use git send.
> The patch applies cleanly, but:
/src/qemu/hw/scsi-disk.c:441: error: 'len' undeclared
Arrgh. Instead of v3 I just re-submitted the old patch which was
white-space damaged before (back then there was a variable "len").
Let's consider it being a test for sending patches via git send. I'll
wear brown paperbag for the next two days.
--
Regards,
Artyom Tarasenko
solaris/sparc under qemu blog: http://tyom.blogspot.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-12-13 10:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-12 19:24 [Qemu-devel] [FOR 0.12 PATCH] scsi-disk: Inquiry with allocation length of CDB < 36 (v3) Artyom Tarasenko
2009-12-13 8:37 ` [Qemu-devel] " Blue Swirl
2009-12-13 10:13 ` Artyom Tarasenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).