]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
ioemu: Two qcow2 bug fixes from upstream qemu.
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 31 Mar 2008 15:39:19 +0000 (16:39 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 31 Mar 2008 15:39:19 +0000 (16:39 +0100)
[Qemu-devel] PATCH: qcow2 image corruption
http://lists.gnu.org/archive/html/qemu-devel/2007-03/msg00773.html

[Qemu-devel] [PATCH] qcow2: release refcount table clusters of the old
table, after growing the refcount table
http://lists.gnu.org/archive/html/qemu-devel/2007-04/msg00043.html

Signed-off-by: Kevin Wolf <kwolf@suse.de>
xen-unstable changeset:   17312:892a20f824a7aa5c5ed57ce80fc61f1dffd4b4d2
xen-unstable date:        Thu Mar 27 17:14:41 2008 +0000

tools/ioemu/block-qcow2.c

index a5f825538957e5841ca02ed9d48fb89259229a4c..64ec49034afa02f254d1b4b3f36a5abcae778ab0 100644 (file)
@@ -1886,6 +1886,8 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size)
     int64_t table_offset;
     uint64_t data64;
     uint32_t data32;
+    int old_table_size;
+    int64_t old_table_offset;
 
     if (min_size <= s->refcount_table_size)
         return 0;
@@ -1931,10 +1933,14 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size)
                     &data32, sizeof(data32)) != sizeof(data32))
         goto fail;
     qemu_free(s->refcount_table);
+    old_table_offset = s->refcount_table_offset;
+    old_table_size = s->refcount_table_size;
     s->refcount_table = new_table;
     s->refcount_table_size = new_table_size;
+    s->refcount_table_offset = table_offset;
 
     update_refcount(bs, table_offset, new_table_size2, 1);
+    free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
     return 0;
  fail:
     free_clusters(bs, table_offset, new_table_size2);