aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2-refcount.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2009-05-28 16:07:05 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-06-16 15:18:36 -0500
commit45aba42fba7ae2a768606e08cece87a4aed987a6 (patch)
treecad76d4e89878cf391ce471ecc0bcd45672c9759 /block/qcow2-refcount.c
parentf7d0fe0239e438c396f5602e18aaf1d615998dfe (diff)
qcow2: Split out guest cluster functions
qcow2-cluster.c contains all functions related to the management of guest clusters, i.e. what the guest sees on its virtual disk. This code is about mapping these guest clusters to host clusters in the image file using the two-level lookup tables. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'block/qcow2-refcount.c')
-rw-r--r--block/qcow2-refcount.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index b70afe9639..3f461c6890 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -389,6 +389,34 @@ void free_clusters(BlockDriverState *bs,
update_refcount(bs, offset, size, -1);
}
+/*
+ * free_any_clusters
+ *
+ * free clusters according to its type: compressed or not
+ *
+ */
+
+void free_any_clusters(BlockDriverState *bs,
+ uint64_t cluster_offset, int nb_clusters)
+{
+ BDRVQcowState *s = bs->opaque;
+
+ /* free the cluster */
+
+ if (cluster_offset & QCOW_OFLAG_COMPRESSED) {
+ int nb_csectors;
+ nb_csectors = ((cluster_offset >> s->csize_shift) &
+ s->csize_mask) + 1;
+ free_clusters(bs, (cluster_offset & s->cluster_offset_mask) & ~511,
+ nb_csectors * 512);
+ return;
+ }
+
+ free_clusters(bs, cluster_offset, nb_clusters << s->cluster_bits);
+
+ return;
+}
+
/*********************************************************/