Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main-src > by-pkgid > aadbe78a25743146bb784eee19f007c5 > files > 498

kvm-83-164.el5_5.9.src.rpm

From 6a25696af7e8ee34f10e03dc043f96e31b6844b2 Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Fri, 26 Mar 2010 15:08:31 -0300
Subject: [PATCH 3/3] qcow2: More checks for qemu-img check

RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <patch-8144-clone-for-rhel55-rhel55>
Patchwork-id: 8381
O-Subject: [RHEL-5.6/5.5.z KVM PATCH 3/3] qcow2: More checks for qemu-img check
Bugzilla: 581766
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Gleb Natapov <gleb@redhat.com>
RH-Acked-by: Christoph Hellwig <chellwig@redhat.com>

Bugzilla: 577225
Upstream commit: 746c3cb5d55a702ba6285e97d2a13671f09285d8

Implement some more refcount block related checks

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qemu/block-qcow2.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu/block-qcow2.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/qemu/block-qcow2.c b/qemu/block-qcow2.c
index 6428808..77fe0b4 100644
--- a/qemu/block-qcow2.c
+++ b/qemu/block-qcow2.c
@@ -3261,9 +3261,21 @@ static int 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]);
+            }
         }
     }
 
-- 
1.7.0.3