From patchwork Mon Feb 15 16:19:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 45401 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 F25B0B7CB9 for ; Tue, 16 Feb 2010 03:27:01 +1100 (EST) Received: from localhost ([127.0.0.1]:32955 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nh3kz-00089U-M5 for incoming@patchwork.ozlabs.org; Mon, 15 Feb 2010 11:25:09 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nh3ga-0007Nl-FB for qemu-devel@nongnu.org; Mon, 15 Feb 2010 11:20:36 -0500 Received: from [199.232.76.173] (port=33675 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nh3ga-0007NW-0w for qemu-devel@nongnu.org; Mon, 15 Feb 2010 11:20:36 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nh3gY-0004bd-TW for qemu-devel@nongnu.org; Mon, 15 Feb 2010 11:20:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:16112) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nh3gY-0004bY-Ft for qemu-devel@nongnu.org; Mon, 15 Feb 2010 11:20:34 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1FGKTcl032654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 15 Feb 2010 11:20:29 -0500 Received: from localhost.localdomain (vpn1-6-194.ams2.redhat.com [10.36.6.194]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1FGKGSe002548; Mon, 15 Feb 2010 11:20:27 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Mon, 15 Feb 2010 17:19:29 +0100 Message-Id: <1266250769-5816-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1266250769-5816-1-git-send-email-kwolf@redhat.com> References: <1266250769-5816-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, hch@lst.de, armbru@redhat.com, gleb@redhat.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 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 Reviewed-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 e7fdf64..e50fb2a 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]); + } } }