Received: from eggs.gnu.org ([208.118.235.92]:50788) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1OXS-0006Z4-BD for qemu-devel@nongnu.org; Fri, 01 Feb 2013 16:56:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U1OWO-00081L-8z for qemu-devel@nongnu.org; Fri, 01 Feb 2013 16:52:50 -0500 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:54291) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1OWO-00080Z-2U for qemu-devel@nongnu.org; Fri, 01 Feb 2013 16:51:44 -0500 From: Stefan Weil Date: Fri, 1 Feb 2013 22:51:32 +0100 Message-Id: <1359755494-28012-6-git-send-email-sw@weilnetz.de> In-Reply-To: <1359755494-28012-1-git-send-email-sw@weilnetz.de> References: <1359755494-28012-1-git-send-email-sw@weilnetz.de> Subject: [Qemu-devel] [PATCH 5/7] block/vpc: Fix size calculation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , Stefan Hajnoczi , qemu-devel@nongnu.org Cc: Stefan Weil , jcody@redhat.com The size calculated from the CHS values is not the real image (disk) size, but usually a smaller value (this is caused by rounding effects). Only older operating systems use CHS. Such guests won't be able to use the whole disk. This patch fixes https://bugs.launchpad.net/qemu/+bug/1105670/. Signed-off-by: Stefan Weil --- block/vpc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/block/vpc.c b/block/vpc.c index fff103b..799b1c9 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -198,11 +198,10 @@ static int vpc_open(BlockDriverState *bs, int flags) /* Write 'checksum' back to footer, or else will leave it with zero. */ footer->checksum = be32_to_cpu(checksum); - // The visible size of a image in Virtual PC depends on the geometry - // rather than on the size stored in the footer (the size in the footer - // is too large usually) - bs->total_sectors = (int64_t) - be16_to_cpu(footer->cyls) * footer->heads * footer->secs_per_cyl; + /* The visible size of an image in Virtual PC may depend on the geometry + * rather than on the size stored in the footer (the size in the footer + * is usually larger). Nevertheless we must use the real size here. */ + bs->total_sectors = be64_to_cpu(footer->size) / 512; /* Allow a maximum disk size of approximately 2 TB */ if (bs->total_sectors >= 65535LL * 255 * 255) { -- 1.7.10.4