From e198214bd38fc938e0d00fd05e6909bb24a12418 Mon Sep 17 00:00:00 2001 From: Kevin Wolf <kwolf@redhat.com> Date: Fri, 26 Mar 2010 15:08:31 -0300 Subject: [PATCH 3/3] qcow2: More checks for qemu-img check RH-Author: Kevin Wolf <kwolf@redhat.com> Message-id: <patch-8144-clone-for-rhel5-rhel56> Patchwork-id: 8382 O-Subject: [RHEL-5.6/5.5.z KVM PATCH 3/3] qcow2: More checks for qemu-img check Bugzilla: 577225 RH-Acked-by: Juan Quintela <quintela@redhat.com> RH-Acked-by: Gleb Natapov <gleb@redhat.com> RH-Acked-by: Christoph Hellwig <chellwig@redhat.com> Bugzilla: 577225 Upstream commit: 746c3cb5d55a702ba6285e97d2a13671f09285d8 Implement some more refcount block related checks Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- qemu/block-qcow2.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- qemu/block-qcow2.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/qemu/block-qcow2.c b/qemu/block-qcow2.c index 6428808..77fe0b4 100644 --- a/qemu/block-qcow2.c +++ b/qemu/block-qcow2.c @@ -3261,9 +3261,21 @@ static int 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.7.0.3