qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Artyom Tarasenko <atar4qemu@googlemail.com>
To: "Krumme, Chris" <Chris.Krumme@windriver.com>
Cc: Blue Swirl <blauwirbel@gmail.com>, qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] scsi disk block descriptor
Date: Tue, 13 Oct 2009 23:39:21 +0200	[thread overview]
Message-ID: <fb8d4f70910131439i5dcf1b6dw9a5d2804b251c37a@mail.gmail.com> (raw)
In-Reply-To: <58BD0469C48A7443A479A13D101685E30332AEA0@ala-mail09.corp.ad.wrs.com>

2009/10/13 Krumme, Chris <Chris.Krumme@windriver.com>:
>
>
>> -----Original Message-----
>> From:
>> qemu-devel-bounces+chris.krumme=windriver.com@nongnu.org
>> [mailto:qemu-devel-bounces+chris.krumme=windriver.com@nongnu.o
>> rg] On Behalf Of Artyom Tarasenko
>> Sent: Tuesday, October 13, 2009 3:20 PM
>> To: qemu-devel; Blue Swirl
>> Subject: [Qemu-devel] [PATCH] scsi disk block descriptor
>>
>> The SCSI-2 documentation suggests, that although the block
>> descriptor is optional for an arbitrary SCSI-2 device (chapter 8.2.10,
>> http://ldkelley.com/SCSI2/SCSI2/SCSI2/SCSI2/SCSI2-08.html )
>> it is mandatory for a disk: chapters 9.1.2, 9.3.3
>> ( http://ldkelley.com/SCSI2/SCSI2/SCSI2/SCSI2-09.html ) don't say
>> "optional" any more, just "The block descriptor in the MODE SENSE
>> data describes the block lengths that are used on the medium."
>>
>> Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
>> ---
>> diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
>> index 3940726..b703379 100644
>> --- a/hw/scsi-disk.c
>> +++ b/hw/scsi-disk.c
>> @@ -624,7 +624,9 @@ static int32_t scsi_send_command(SCSIDevice *d,
>> uint32_t tag,
>>          {
>>              uint8_t *p;
>>              int page;
>> -
>> +            int dbd;
>> +
>> +            dbd = buf[1]  & 0x8;
>>              page = buf[2] & 0x3f;
>>              DPRINTF("Mode Sense (page %d, len %d)\n", page, len);
>>              p = outbuf;
>> @@ -635,6 +637,24 @@ static int32_t scsi_send_command(SCSIDevice *d,
>> uint32_t tag,
>>                  outbuf[2] = 0x80; /* Readonly.  */
>>              }
>>              p += 4;
>> +            bdrv_get_geometry(s->dinfo->bdrv, &nb_sectors);
>> +            if ((~dbd) & nb_sectors) {
>> +                nb_sectors /= s->cluster_size;
>> +                if (nb_sectors > UINT32_MAX)
>> +                    nb_sectors = UINT32_MAX;
>> +                nb_sectors--;
>> +                outbuf[3] = 8; /* Block descriptor length  */
>> +                p[0] = 0; /* media density code */
>> +                p[1] = (nb_sectors >> 16) & 0xff;
>> +                p[2] = (nb_sectors >> 8) & 0xff;
>> +                p[3] = nb_sectors & 0xff;
>
> Hello Artyom,
>
> Above you limit to 32 bits - 1, then you use the bottom 24 bits.  Would
> it be better to limit to 24 bits - 1, then a drive with more than 24
> bits of sectors will show as maximum size rather than a random size?

Thanks, Chris!

      reply	other threads:[~2009-10-13 21:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-13 20:20 [Qemu-devel] [PATCH] scsi disk block descriptor Artyom Tarasenko
2009-10-13 20:34 ` Krumme, Chris
2009-10-13 21:39   ` Artyom Tarasenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fb8d4f70910131439i5dcf1b6dw9a5d2804b251c37a@mail.gmail.com \
    --to=atar4qemu@googlemail.com \
    --cc=Chris.Krumme@windriver.com \
    --cc=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).