]> Git Repo - qemu.git/blobdiff - block/qcow2-refcount.c
qcow2: More checks for qemu-img check
[qemu.git] / block / qcow2-refcount.c
index f714ca2df7bf9d4597408a495e34c156f40d644f..917fc88d9c888b5265cb8afe4b86fc2607bccadf 100644 (file)
@@ -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]);
+            }
         }
     }
 
This page took 0.022533 seconds and 4 git commands to generate.