From: Keir Fraser Date: Mon, 31 Mar 2008 15:39:19 +0000 (+0100) Subject: ioemu: Two qcow2 bug fixes from upstream qemu. X-Git-Tag: 3.2.1-rc3~12 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=82ea6129577e0a25a0f48851e3b25389ac0cb01e;p=people%2Fvhanquez%2Fxen.git ioemu: Two qcow2 bug fixes from upstream qemu. [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 xen-unstable changeset: 17312:892a20f824a7aa5c5ed57ce80fc61f1dffd4b4d2 xen-unstable date: Thu Mar 27 17:14:41 2008 +0000 --- diff --git a/tools/ioemu/block-qcow2.c b/tools/ioemu/block-qcow2.c index a5f825538..64ec49034 100644 --- a/tools/ioemu/block-qcow2.c +++ b/tools/ioemu/block-qcow2.c @@ -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);