From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:41393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RNSQt-0002CV-JR for qemu-devel@nongnu.org; Mon, 07 Nov 2011 11:52:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RNSQn-0004pY-Qu for qemu-devel@nongnu.org; Mon, 07 Nov 2011 11:52:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47071) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RNSQn-0004pQ-EI for qemu-devel@nongnu.org; Mon, 07 Nov 2011 11:52:21 -0500 From: Kevin Wolf Date: Mon, 7 Nov 2011 17:55:14 +0100 Message-Id: <1320684918-6483-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1320684918-6483-1-git-send-email-kwolf@redhat.com> References: <1320684918-6483-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 07/11] vvfat: do not fail if the disk has spare sectors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Paolo Bonzini If the number of "faked sectors" + the number of sectors that are part of a cluster does not sum up to the total number of sectors, qemu-img convert fails. Read these spare sectors as all zeros. Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- block/vvfat.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index 75d0dc0..9f851b0 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1245,7 +1245,7 @@ static int vvfat_read(BlockDriverState *bs, int64_t sector_num, int i; for(i=0;i= s->sector_count) + if (sector_num >= bs->total_sectors) return -1; if (s->qcow) { int n; @@ -1271,7 +1271,7 @@ DLOG(fprintf(stderr, "sector %d not allocated\n", (int)sector_num)); uint32_t sector=sector_num-s->faked_sectors, sector_offset_in_cluster=(sector%s->sectors_per_cluster), cluster_num=sector/s->sectors_per_cluster; - if(read_cluster(s, cluster_num) != 0) { + if(cluster_num > s->cluster_count || read_cluster(s, cluster_num) != 0) { /* LATER TODO: strict: return -1; */ memset(buf+i*0x200,0,0x200); continue; -- 1.7.6.4