]> git.proxmox.com Git - qemu.git/commitdiff
qemu-img check: Print fixed clusters and recheck
authorKevin Wolf <kwolf@redhat.com>
Fri, 11 May 2012 16:16:54 +0000 (18:16 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 15 Jun 2012 12:03:42 +0000 (14:03 +0200)
When any inconsistencies have been fixed, print the statistics and run
another check to make sure everything is correct now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.h
block/qed-check.c
qemu-img.c

diff --git a/block.h b/block.h
index 61b7e8ecb9448da193dd85d3e525d1340a4ed10e..f8200ebdf8e41e9d2228dd5738b595f82d3039be 100644 (file)
--- a/block.h
+++ b/block.h
@@ -187,6 +187,8 @@ typedef struct BdrvCheckResult {
     int corruptions;
     int leaks;
     int check_errors;
+    int corruptions_fixed;
+    int leaks_fixed;
     BlockFragInfo bfi;
 } BdrvCheckResult;
 
index 94327ff5b339f0d1cf1742f1a2cf2c9716030bf2..5edf60775b83d914963dc294def50e299965eb24 100644 (file)
@@ -87,6 +87,7 @@ static unsigned int qed_check_l2_table(QEDCheck *check, QEDTable *table)
         if (!qed_check_cluster_offset(s, offset)) {
             if (check->fix) {
                 table->offsets[i] = 0;
+                check->result->corruptions_fixed++;
             } else {
                 check->result->corruptions++;
             }
@@ -127,6 +128,7 @@ static int qed_check_l1_table(QEDCheck *check, QEDTable *table)
             /* Clear invalid offset */
             if (check->fix) {
                 table->offsets[i] = 0;
+                check->result->corruptions_fixed++;
             } else {
                 check->result->corruptions++;
             }
index c45ff62a28b9ee1c6c5662c855d4a257c35e92d2..9336c86d9eb00bd31e63d653504d01aa312e8548 100644 (file)
@@ -425,6 +425,16 @@ static int img_check(int argc, char **argv)
         return 1;
     }
 
+    if (result.corruptions_fixed || result.leaks_fixed) {
+        printf("The following inconsistencies were found and repaired:\n\n"
+               "    %d leaked clusters\n"
+               "    %d corruptions\n\n"
+               "Double checking the fixed image now...\n",
+               result.leaks_fixed,
+               result.corruptions_fixed);
+        ret = bdrv_check(bs, &result, 0);
+    }
+
     if (!(result.corruptions || result.leaks || result.check_errors)) {
         printf("No errors were found on the image.\n");
     } else {