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.h | |
parent | f7d0fe0239e438c396f5602e18aaf1d615998dfe (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.h')
-rw-r--r-- | block/qcow2.h | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/block/qcow2.h b/block/qcow2.h index 3a34212181..367d9bdbb5 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -124,7 +124,16 @@ typedef struct QCowCreateState { int64_t refcount_block_offset; } QCowCreateState; -static int size_to_clusters(BDRVQcowState *s, int64_t size) +/* XXX This could be private for qcow2-cluster.c */ +typedef struct QCowL2Meta +{ + uint64_t offset; + int n_start; + int nb_available; + int nb_clusters; +} QCowL2Meta; + +static inline int size_to_clusters(BDRVQcowState *s, int64_t size) { return (size + (s->cluster_size - 1)) >> s->cluster_bits; } @@ -133,6 +142,8 @@ static int size_to_clusters(BDRVQcowState *s, int64_t size) /* qcow2.c functions */ void l2_cache_reset(BlockDriverState *bs); +int backing_read1(BlockDriverState *bs, + int64_t sector_num, uint8_t *buf, int nb_sectors); /* qcow2-refcount.c functions */ int refcount_init(BlockDriverState *bs); @@ -141,7 +152,9 @@ void refcount_close(BlockDriverState *bs); int64_t alloc_clusters(BlockDriverState *bs, int64_t size); int64_t alloc_bytes(BlockDriverState *bs, int size); void free_clusters(BlockDriverState *bs, - int64_t offset, int64_t size); + int64_t offset, int64_t size); +void free_any_clusters(BlockDriverState *bs, + uint64_t cluster_offset, int nb_clusters); void create_refcount_update(QCowCreateState *s, int64_t offset, int64_t size); int update_snapshot_refcount(BlockDriverState *bs, @@ -151,4 +164,24 @@ int update_snapshot_refcount(BlockDriverState *bs, int check_refcounts(BlockDriverState *bs); +/* qcow2-cluster.c functions */ +int grow_l1_table(BlockDriverState *bs, int min_size); +int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset); +void encrypt_sectors(BDRVQcowState *s, int64_t sector_num, + uint8_t *out_buf, const uint8_t *in_buf, + int nb_sectors, int enc, + const AES_KEY *key); + +uint64_t get_cluster_offset(BlockDriverState *bs, uint64_t offset, int *num); +uint64_t alloc_cluster_offset(BlockDriverState *bs, + uint64_t offset, + int n_start, int n_end, + int *num, QCowL2Meta *m); +uint64_t alloc_compressed_cluster_offset(BlockDriverState *bs, + uint64_t offset, + int compressed_size); + +int alloc_cluster_link_l2(BlockDriverState *bs, uint64_t cluster_offset, + QCowL2Meta *m); + #endif |