aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2.h
diff options
context:
space:
mode:
authorAlberto Garcia <berto@igalia.com>2020-07-10 18:12:48 +0200
committerMax Reitz <mreitz@redhat.com>2020-08-25 08:33:20 +0200
commit12c6aebedfb6b90d5f019ab536dd3f2752e6e361 (patch)
tree496536e3698896e7bd84fd5e8c01d47997484a32 /block/qcow2.h
parent57538c864f3ad67d515892fd54b11ff59981b84d (diff)
downloadqemu-12c6aebedfb6b90d5f019ab536dd3f2752e6e361.zip
qemu-12c6aebedfb6b90d5f019ab536dd3f2752e6e361.tar.gz
qemu-12c6aebedfb6b90d5f019ab536dd3f2752e6e361.tar.bz2
qcow2: Add get_l2_entry() and set_l2_entry()
The size of an L2 entry is 64 bits, but if we want to have subclusters we need extended L2 entries. This means that we have to access L2 tables and slices differently depending on whether an image has extended L2 entries or not. This patch replaces all l2_slice[] accesses with calls to get_l2_entry() and set_l2_entry(). Signed-off-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <9586363531fec125ba1386e561762d3e4224e9fc.1594396418.git.berto@igalia.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/qcow2.h')
-rw-r--r--block/qcow2.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/block/qcow2.h b/block/qcow2.h
index 06475e0..eecbadc 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -510,6 +510,18 @@ typedef enum QCow2MetadataOverlap {
#define INV_OFFSET (-1ULL)
+static inline uint64_t get_l2_entry(BDRVQcow2State *s, uint64_t *l2_slice,
+ int idx)
+{
+ return be64_to_cpu(l2_slice[idx]);
+}
+
+static inline void set_l2_entry(BDRVQcow2State *s, uint64_t *l2_slice,
+ int idx, uint64_t entry)
+{
+ l2_slice[idx] = cpu_to_be64(entry);
+}
+
static inline bool has_data_file(BlockDriverState *bs)
{
BDRVQcow2State *s = bs->opaque;