aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2-snapshot.c
diff options
context:
space:
mode:
authorAlberto Garcia <berto@igalia.com>2020-08-28 13:08:28 +0200
committerMax Reitz <mreitz@redhat.com>2020-09-15 11:05:12 +0200
commit02b1ecfa100e7ecc2306560cd27a4a2622bfeb04 (patch)
treefd2067510fcef3381b01bae8719756e27533c9a0 /block/qcow2-snapshot.c
parentaf8d43d3933a4bec0977b9f33d69443a2d166861 (diff)
downloadqemu-02b1ecfa100e7ecc2306560cd27a4a2622bfeb04.zip
qemu-02b1ecfa100e7ecc2306560cd27a4a2622bfeb04.tar.gz
qemu-02b1ecfa100e7ecc2306560cd27a4a2622bfeb04.tar.bz2
qcow2: Use macros for the L1, refcount and bitmap table entry sizes
This patch replaces instances of sizeof(uint64_t) in the qcow2 driver with macros that indicate what those sizes are actually referring to. Signed-off-by: Alberto Garcia <berto@igalia.com> Message-Id: <20200828110828.13833-1-berto@igalia.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/qcow2-snapshot.c')
-rw-r--r--block/qcow2-snapshot.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index 2756b37..9b68690 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -659,7 +659,7 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
sn->extra_data_size = sizeof(QCowSnapshotExtraData);
/* Allocate the L1 table of the snapshot and copy the current one there. */
- l1_table_offset = qcow2_alloc_clusters(bs, s->l1_size * sizeof(uint64_t));
+ l1_table_offset = qcow2_alloc_clusters(bs, s->l1_size * L1E_SIZE);
if (l1_table_offset < 0) {
ret = l1_table_offset;
goto fail;
@@ -679,13 +679,13 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
}
ret = qcow2_pre_write_overlap_check(bs, 0, sn->l1_table_offset,
- s->l1_size * sizeof(uint64_t), false);
+ s->l1_size * L1E_SIZE, false);
if (ret < 0) {
goto fail;
}
ret = bdrv_pwrite(bs->file, sn->l1_table_offset, l1_table,
- s->l1_size * sizeof(uint64_t));
+ s->l1_size * L1E_SIZE);
if (ret < 0) {
goto fail;
}
@@ -768,7 +768,7 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
sn = &s->snapshots[snapshot_index];
ret = qcow2_validate_table(bs, sn->l1_table_offset, sn->l1_size,
- sizeof(uint64_t), QCOW_MAX_L1_SIZE,
+ L1E_SIZE, QCOW_MAX_L1_SIZE,
"Snapshot L1 table", &local_err);
if (ret < 0) {
error_report_err(local_err);
@@ -803,8 +803,8 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id)
goto fail;
}
- cur_l1_bytes = s->l1_size * sizeof(uint64_t);
- sn_l1_bytes = sn->l1_size * sizeof(uint64_t);
+ cur_l1_bytes = s->l1_size * L1E_SIZE;
+ sn_l1_bytes = sn->l1_size * L1E_SIZE;
/*
* Copy the snapshot L1 table to the current L1 table.
@@ -917,7 +917,7 @@ int qcow2_snapshot_delete(BlockDriverState *bs,
sn = s->snapshots[snapshot_index];
ret = qcow2_validate_table(bs, sn.l1_table_offset, sn.l1_size,
- sizeof(uint64_t), QCOW_MAX_L1_SIZE,
+ L1E_SIZE, QCOW_MAX_L1_SIZE,
"Snapshot L1 table", errp);
if (ret < 0) {
return ret;
@@ -953,7 +953,7 @@ int qcow2_snapshot_delete(BlockDriverState *bs,
error_setg_errno(errp, -ret, "Failed to free the cluster and L1 table");
return ret;
}
- qcow2_free_clusters(bs, sn.l1_table_offset, sn.l1_size * sizeof(uint64_t),
+ qcow2_free_clusters(bs, sn.l1_table_offset, sn.l1_size * L1E_SIZE,
QCOW2_DISCARD_SNAPSHOT);
/* must update the copied flag on the current cluster offsets */
@@ -1030,12 +1030,12 @@ int qcow2_snapshot_load_tmp(BlockDriverState *bs,
/* Allocate and read in the snapshot's L1 table */
ret = qcow2_validate_table(bs, sn->l1_table_offset, sn->l1_size,
- sizeof(uint64_t), QCOW_MAX_L1_SIZE,
+ L1E_SIZE, QCOW_MAX_L1_SIZE,
"Snapshot L1 table", errp);
if (ret < 0) {
return ret;
}
- new_l1_bytes = sn->l1_size * sizeof(uint64_t);
+ new_l1_bytes = sn->l1_size * L1E_SIZE;
new_l1_table = qemu_try_blockalign(bs->file->bs, new_l1_bytes);
if (new_l1_table == NULL) {
return -ENOMEM;