From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NjwtQ-00026l-Le for qemu-devel@nongnu.org; Tue, 23 Feb 2010 10:41:48 -0500 Received: from [199.232.76.173] (port=39460 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjwtQ-00026U-15 for qemu-devel@nongnu.org; Tue, 23 Feb 2010 10:41:48 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NjwtN-0000pj-Vb for qemu-devel@nongnu.org; Tue, 23 Feb 2010 10:41:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15790) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NjwtN-0000pb-3V for qemu-devel@nongnu.org; Tue, 23 Feb 2010 10:41:45 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1NFfiTl023055 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 23 Feb 2010 10:41:44 -0500 From: Kevin Wolf Date: Tue, 23 Feb 2010 16:40:54 +0100 Message-Id: <1266939654-26510-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1266939654-26510-1-git-send-email-kwolf@redhat.com> References: <1266939654-26510-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH v2 3/3] qcow2: More checks for qemu-img check List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, quintela@redhat.com Implement some more refcount block related checks Signed-off-by: Kevin Wolf --- block/qcow2-refcount.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index f714ca2..917fc88 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1065,9 +1065,21 @@ int qcow2_check_refcounts(BlockDriverState *bs) for(i = 0; i < s->refcount_table_size; i++) { int64_t offset; offset = s->refcount_table[i]; + + /* Refcount blocks are cluster aligned */ + if (offset & (s->cluster_size - 1)) { + fprintf(stderr, "ERROR refcount block %d is not " + "cluster aligned; refcount table entry corrupted\n", i); + errors++; + } + if (offset != 0) { errors += inc_refcounts(bs, refcount_table, nb_clusters, offset, s->cluster_size); + if (refcount_table[offset / s->cluster_size] != 1) { + fprintf(stderr, "ERROR refcount block %d refcount=%d\n", + i, refcount_table[offset / s->cluster_size]); + } } } -- 1.6.6.1