[6212] Fix compressed qcow2 (Gleb Natapov)
Revision: 6212
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6212 Author: aliguori Date: 2009-01-07 16:43:13 +0000 (Wed, 07 Jan 2009)
Log Message:
-----------
Fix compressed qcow2 (Gleb Natapov)
Correctly calculate number of contiguous clusters.
Acked-by Kevin Wolf <[email protected]>
Signed-off-by Gleb Natapov <[email protected]>
Signed-off-by Anthony Liguori <[email protected]>
Modified Paths:
--------------
trunk/block-qcow2.c
Modified: trunk/block-qcow2.c
===================================================================
block-qcow2.c +9 -6
@@ -620,6 +620,9 @@int i;uint64_t offset =be64_to_cpu (l2_table[0 ]) & ~mask; +if (!offset) +return 0 ; +for (i =0 ; i < nb_clusters; i++)if (offset + i * cluster_size != (be64_to_cpu (l2_table[i]) & ~mask))break ;
@@ -981,6 +984,12 @@/* 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 (be64_to_cpu (l2_table[l2_index + i])) +break ; + i +=count_contiguous_free_clusters (nb_clusters - i, &l2_table[l2_index + i]);
@@ -989,12 +998,6 @@if ((cluster_offset &QCOW_OFLAG_COPIED ) || (cluster_offset &QCOW_OFLAG_COMPRESSED ))break ; - - i +=count_contiguous_clusters (nb_clusters - i, s->cluster_size, - &l2_table[l2_index + i],0 ); - -if (be64_to_cpu (l2_table[l2_index + i])) -break ; } nb_clusters = i;