diff options
author | Alberto Garcia <berto@igalia.com> | 2020-07-10 18:12:54 +0200 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2020-08-25 08:33:20 +0200 |
commit | c8fd8554d972904bd0b04673298fea1af7a37780 (patch) | |
tree | cde7c8538b6ceb2d287310a2c7b4fb523ef56daa /block/qcow2.h | |
parent | 3e71981592a9f9c52833887f5675b3154d23eec8 (diff) | |
download | qemu-c8fd8554d972904bd0b04673298fea1af7a37780.zip qemu-c8fd8554d972904bd0b04673298fea1af7a37780.tar.gz qemu-c8fd8554d972904bd0b04673298fea1af7a37780.tar.bz2 |
qcow2: Add l2_entry_size()
qcow2 images with subclusters have 128-bit L2 entries. The first 64
bits contain the same information as traditional images and the last
64 bits form a bitmap with the status of each individual subcluster.
Because of that we cannot assume that L2 entries are sizeof(uint64_t)
anymore. This function returns the proper value for the image.
Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <d34d578bd0380e739e2dde3e8dd6187d3d249fa9.1594396418.git.berto@igalia.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/qcow2.h')
-rw-r--r-- | block/qcow2.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/block/qcow2.h b/block/qcow2.h index 4fe31ad..46b3512 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -80,6 +80,10 @@ #define QCOW_EXTL2_SUBCLUSTERS_PER_CLUSTER 32 +/* Size of normal and extended L2 entries */ +#define L2E_SIZE_NORMAL (sizeof(uint64_t)) +#define L2E_SIZE_EXTENDED (sizeof(uint64_t) * 2) + #define MIN_CLUSTER_BITS 9 #define MAX_CLUSTER_BITS 21 @@ -521,6 +525,11 @@ static inline bool has_subclusters(BDRVQcow2State *s) return false; } +static inline size_t l2_entry_size(BDRVQcow2State *s) +{ + return has_subclusters(s) ? L2E_SIZE_EXTENDED : L2E_SIZE_NORMAL; +} + static inline uint64_t get_l2_entry(BDRVQcow2State *s, uint64_t *l2_slice, int idx) { |