From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LSBnF-0003rL-Qr for qemu-devel@nongnu.org; Wed, 28 Jan 2009 09:53:29 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LSBnE-0003qW-RX for qemu-devel@nongnu.org; Wed, 28 Jan 2009 09:53:28 -0500 Received: from [199.232.76.173] (port=43711 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LSBnE-0003qH-8u for qemu-devel@nongnu.org; Wed, 28 Jan 2009 09:53:28 -0500 Received: from shelob.surriel.com ([74.92.59.67]:49153) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LSBnD-0001T9-Gs for qemu-devel@nongnu.org; Wed, 28 Jan 2009 09:53:27 -0500 Received: from [2002:4a5c:3b41:1:213:72ff:fe17:4a9c] (helo=bree.surriel.com ident=[U2FsdGVkX1+7DdpZH+SrMRS0vuXtAKs2KnXmK2dBmKM=]) by shelob.surriel.com with esmtp (Exim 4.63) (envelope-from ) id 1LSBnB-00043W-Pv for qemu-devel@nongnu.org; Wed, 28 Jan 2009 09:53:25 -0500 Received: from bree.surriel.com (localhost [127.0.0.1] (may be forged)) by bree.surriel.com (8.13.8/8.13.8) with ESMTP id n0SErPEX011875 for ; Wed, 28 Jan 2009 09:53:25 -0500 Message-Id: <20090128145211.871815000@redhat.com> References: <20090128145137.396187000@redhat.com> Date: Wed, 28 Jan 2009 09:51:40 -0500 From: Rik van Riel Content-Disposition: inline; filename=qemu-capacity-sectors.patch Subject: [Qemu-devel] [PATCH 3/3] SCSI divide capacity by s->cluster_size Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Paul Brook pointed out that the number of sectors reported by the SCSI read capacity commands needs to be divided by s->cluster_size, because bdrv_get_geometry reports the number of 512 byte sectors, while emulated CDROMs report 2048 byte sectors back to the guest. This has no consequences for emulated hard disks, which use a cluster size of 1. Signed-off-by: Rik van Riel Index: qemu/trunk/hw/scsi-disk.c =================================================================== --- qemu.orig/trunk/hw/scsi-disk.c +++ qemu/trunk/hw/scsi-disk.c @@ -734,6 +734,7 @@ static int32_t scsi_send_command(SCSIDev /* The normal LEN field for this command is zero. */ memset(outbuf, 0, 8); bdrv_get_geometry(s->bdrv, &nb_sectors); + nb_sectors =/ s->cluster_size; /* Returned value is the address of the last sector. */ if (nb_sectors) { nb_sectors--; @@ -834,6 +835,7 @@ static int32_t scsi_send_command(SCSIDev DPRINTF("SAI READ CAPACITY(16)\n"); memset(outbuf, 0, len); bdrv_get_geometry(s->bdrv, &nb_sectors); + nb_sectors =/ s->cluster_size; /* Returned value is the address of the last sector. */ if (nb_sectors) { nb_sectors--; -- All rights reversed.