diff options
author | Kevin Wolf <kwolf@redhat.com> | 2009-05-28 16:07:05 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-06-16 15:18:36 -0500 |
commit | 45aba42fba7ae2a768606e08cece87a4aed987a6 (patch) | |
tree | cad76d4e89878cf391ce471ecc0bcd45672c9759 /block/qcow2-refcount.c | |
parent | qcow2: Split out refcount handling (diff) | |
download | qemu-kvm-45aba42fba7ae2a768606e08cece87a4aed987a6.tar.gz qemu-kvm-45aba42fba7ae2a768606e08cece87a4aed987a6.tar.bz2 qemu-kvm-45aba42fba7ae2a768606e08cece87a4aed987a6.zip |
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.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index b70afe963..3f461c689 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; +} + /*********************************************************/ |