Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mxp5w-0000oL-Tv for qemu-devel@nongnu.org; Tue, 13 Oct 2009 17:39:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mxp5r-0000jg-Mo for qemu-devel@nongnu.org; Tue, 13 Oct 2009 17:39:48 -0400 Received: from [199.232.76.173] (port=50236 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mxp5r-0000jd-11 for qemu-devel@nongnu.org; Tue, 13 Oct 2009 17:39:43 -0400 Received: from mail-gx0-f225.google.com ([209.85.217.225]:34045) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mxp5q-0003go-O0 for qemu-devel@nongnu.org; Tue, 13 Oct 2009 17:39:42 -0400 Received: by gxk25 with SMTP id 25so11278475gxk.16 for ; Tue, 13 Oct 2009 14:39:42 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <58BD0469C48A7443A479A13D101685E30332AEA0@ala-mail09.corp.ad.wrs.com> References: <58BD0469C48A7443A479A13D101685E30332AEA0@ala-mail09.corp.ad.wrs.com> From: Artyom Tarasenko Date: Tue, 13 Oct 2009 23:39:21 +0200 Message-ID: Subject: Re: [Qemu-devel] [PATCH] scsi disk block descriptor Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Krumme, Chris" Cc: Blue Swirl , qemu-devel 2009/10/13 Krumme, Chris : > > >> -----Original Message----- >> From: >> qemu-devel-bounces+chris.krumme=3Dwindriver.com@nongnu.org >> [mailto:qemu-devel-bounces+chris.krumme=3Dwindriver.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 >> --- >> 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, >> =A0 =A0 =A0 =A0 =A0{ >> =A0 =A0 =A0 =A0 =A0 =A0 =A0uint8_t *p; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0int page; >> - >> + =A0 =A0 =A0 =A0 =A0 =A0int dbd; >> + >> + =A0 =A0 =A0 =A0 =A0 =A0dbd =3D buf[1] =A0& 0x8; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0page =3D buf[2] & 0x3f; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0DPRINTF("Mode Sense (page %d, len %d)\n", pag= e, len); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0p =3D outbuf; >> @@ -635,6 +637,24 @@ static int32_t scsi_send_command(SCSIDevice *d, >> uint32_t tag, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0outbuf[2] =3D 0x80; /* Readonly. =A0*= / >> =A0 =A0 =A0 =A0 =A0 =A0 =A0} >> =A0 =A0 =A0 =A0 =A0 =A0 =A0p +=3D 4; >> + =A0 =A0 =A0 =A0 =A0 =A0bdrv_get_geometry(s->dinfo->bdrv, &nb_sectors); >> + =A0 =A0 =A0 =A0 =A0 =A0if ((~dbd) & nb_sectors) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0nb_sectors /=3D s->cluster_size; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (nb_sectors > UINT32_MAX) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0nb_sectors =3D UINT32_MAX; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0nb_sectors--; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0outbuf[3] =3D 8; /* Block descriptor le= ngth =A0*/ >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0p[0] =3D 0; /* media density code */ >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0p[1] =3D (nb_sectors >> 16) & 0xff; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0p[2] =3D (nb_sectors >> 8) & 0xff; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0p[3] =3D nb_sectors & 0xff; > > Hello Artyom, > > Above you limit to 32 bits - 1, then you use the bottom 24 bits. =A0Would > 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!