diff -u qemu-kvm-1.0+noroms/debian/changelog qemu-kvm-1.0+noroms/debian/changelog --- qemu-kvm-1.0+noroms/debian/changelog +++ qemu-kvm-1.0+noroms/debian/changelog @@ -1,3 +1,10 @@ +qemu-kvm (1.0+noroms-0ubuntu14.9~lp1189926) precise; urgency=low + + * 9004-qcow2-Simplify-count_cow_clusters.patch: fixes corruption + with qcow2. (LP: #1189926) + + -- Chris J Arges Wed, 12 Jun 2013 13:19:46 -0500 + qemu-kvm (1.0+noroms-0ubuntu14.8) precise-proposed; urgency=low * qemu-utils.links: fix kvm-nbd.8.gz and kvm-img.1.gz symlinks. (LP: #1089402) diff -u qemu-kvm-1.0+noroms/debian/patches/series qemu-kvm-1.0+noroms/debian/patches/series --- qemu-kvm-1.0+noroms/debian/patches/series +++ qemu-kvm-1.0+noroms/debian/patches/series @@ -32,0 +33 @@ +9004-qcow2-Simplify-count_cow_clusters.patch only in patch2: unchanged: --- qemu-kvm-1.0+noroms.orig/debian/patches/9004-qcow2-Simplify-count_cow_clusters.patch +++ qemu-kvm-1.0+noroms/debian/patches/9004-qcow2-Simplify-count_cow_clusters.patch @@ -0,0 +1,58 @@ +From: Kevin Wolf +Date: Wed, 12 Jun 2013 10:48:22 -0500 +Subject: [PATCH] qcow2: Simplify count_cow_clusters + +count_cow_clusters() tries to reuse existing functions, and all it +achieves is to make things much more complicated than they really are: +Everything needs COW, unless it's a normal cluster with refcount 1. + +This patch implements the obvious way of doing this, and by using +qcow2_get_cluster_type() it gets rid of all flag magic. + +Signed-off-by: Kevin Wolf +(backported from commit 143550a83ef4eef86a847d00023d148e1f59f743) +Signed-off-by: Chris J Arges +--- + block/qcow2-cluster.c | 23 ++++++----------------- + 1 file changed, 6 insertions(+), 17 deletions(-) + +diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c +index f4e049f..db45348 100644 +--- a/block/qcow2-cluster.c ++++ b/block/qcow2-cluster.c +@@ -748,26 +748,15 @@ again: + nb_clusters = 1; + + /* how many available clusters ? */ +- +- while (i < nb_clusters) { +- i += count_contiguous_clusters(nb_clusters - i, s->cluster_size, +- &l2_table[l2_index], i, 0); +- if ((i >= nb_clusters) || be64_to_cpu(l2_table[l2_index + i])) { +- break; +- } +- +- i += count_contiguous_free_clusters(nb_clusters - i, +- &l2_table[l2_index + i]); +- if (i >= nb_clusters) { ++ for (i = 0; i < nb_clusters; i++) { ++ uint64_t l2_entry = be64_to_cpu(l2_table[l2_index + i]); ++ if (l2_entry & QCOW_OFLAG_COPIED) { ++ goto out_count; ++ } else if (l2_entry & QCOW_OFLAG_COMPRESSED) { + break; + } +- +- cluster_offset = be64_to_cpu(l2_table[l2_index + i]); +- +- if ((cluster_offset & QCOW_OFLAG_COPIED) || +- (cluster_offset & QCOW_OFLAG_COMPRESSED)) +- break; + } ++out_count: + assert(i <= nb_clusters); + nb_clusters = i; + +-- +1.7.9.5 +