From: Kevin Wolf Date: Tue, 23 Feb 2010 15:40:54 +0000 (+0100) Subject: qcow2: More checks for qemu-img check X-Git-Tag: v0.13.0-rc0~1276 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=746c3cb5d55a702ba6285e97d2a13671f09285d8;p=thirdparty%2Fqemu.git qcow2: More checks for qemu-img check Implement some more refcount block related checks Signed-off-by: Kevin Wolf Signed-off-by: Anthony Liguori --- diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index f714ca2df7b..917fc88d9c8 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]); + } } }