From patchwork Tue Feb 23 15:40:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 46071 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2E37CB7D06 for ; Wed, 24 Feb 2010 02:48:01 +1100 (EST) Received: from localhost ([127.0.0.1]:45761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjwzO-00040l-5Q for incoming@patchwork.ozlabs.org; Tue, 23 Feb 2010 10:47:58 -0500 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 Received: from localhost.localdomain (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1NFfc9L023357; Tue, 23 Feb 2010 10:41:43 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH v2 3/3] qcow2: More checks for qemu-img check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Implement some more refcount block related checks Signed-off-by: Kevin Wolf Acked-by: Juan Quintela --- 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]); + } } }