aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2-refcount.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2010-02-23 16:40:54 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2010-02-23 13:23:29 -0600
commit746c3cb5d55a702ba6285e97d2a13671f09285d8 (patch)
treef681ca148674b3d2733404e62c04191de9def260 /block/qcow2-refcount.c
parent92dcb59fd4e1491afa0756ee9c2594869b487d23 (diff)
downloadqemu-746c3cb5d55a702ba6285e97d2a13671f09285d8.zip
qemu-746c3cb5d55a702ba6285e97d2a13671f09285d8.tar.gz
qemu-746c3cb5d55a702ba6285e97d2a13671f09285d8.tar.bz2
qcow2: More checks for qemu-img check
Implement some more refcount block related checks Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'block/qcow2-refcount.c')
-rw-r--r--block/qcow2-refcount.c12
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]);
+ }
}
}