On 2014-11-28 at 12:11, Stefan Hajnoczi wrote:
On Thu, Nov 20, 2014 at 06:06:23PM +0100, Max Reitz wrote:
@@ -1711,7 +1746,7 @@ static int calculate_refcounts(BlockDriverState *bs, 
BdrvCheckResult *res,
  static void compare_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
                                BdrvCheckMode fix, bool *rebuild,
                                int64_t *highest_cluster,
-                              uint16_t *refcount_table, int64_t nb_clusters)
+                              void *refcount_table, int64_t nb_clusters)
  {
      BDRVQcowState *s = bs->opaque;
      int64_t i, refcount1, refcount2;
An -ERANGE qcow2_get_refcount() return value is treated as a check error
here and we won't be able to rebuild the refcount blocks:

   refcount1 = qcow2_get_refcount(bs, i);
   if (refcount1 < 0) {
       fprintf(stderr, "Can't get refcount for cluster %" PRId64 ": %s\n",
           i, strerror(-refcount1));
       res->check_errors++;
       continue;
   }

We should allow rebuilding refcount blocks, -ERANGE is just another
corrupted refcount.

Right, hopefully this will be fixed by implementing your proposal for changing "uint64_t qcow2_get_refcount(...)" to "int qcow2_get_refcount(..., uint64_t *)" etc..

Max

Reply via email to