[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 4/4] qcow2: Use BDRV_SECTOR_SIZE instead of the hardcoded valu
From: |
Alberto Garcia |
Subject: |
[PATCH v2 4/4] qcow2: Use BDRV_SECTOR_SIZE instead of the hardcoded value |
Date: |
Thu, 9 Jan 2020 20:13:02 +0100 |
This replaces all remaining instances in the qcow2 code.
Signed-off-by: Alberto Garcia <address@hidden>
---
block/qcow2-cluster.c | 2 +-
block/qcow2.c | 10 ++++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 932fc48919..777ca2d409 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -219,7 +219,7 @@ static int l2_load(BlockDriverState *bs, uint64_t offset,
* Writes one sector of the L1 table to the disk (can't update single entries
* and we really don't want bdrv_pread to perform a read-modify-write)
*/
-#define L1_ENTRIES_PER_SECTOR (512 / 8)
+#define L1_ENTRIES_PER_SECTOR (BDRV_SECTOR_SIZE / 8)
int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index)
{
BDRVQcow2State *s = bs->opaque;
diff --git a/block/qcow2.c b/block/qcow2.c
index 783d2b9578..c0f3e715ef 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3280,7 +3280,8 @@ qcow2_co_create(BlockdevCreateOptions *create_options,
Error **errp)
/* Validate options and set default values */
if (!QEMU_IS_ALIGNED(qcow2_opts->size, BDRV_SECTOR_SIZE)) {
- error_setg(errp, "Image size must be a multiple of 512 bytes");
+ error_setg(errp, "Image size must be a multiple of %u bytes",
+ (unsigned) BDRV_SECTOR_SIZE);
ret = -EINVAL;
goto out;
}
@@ -3836,7 +3837,7 @@ qcow2_co_copy_range_from(BlockDriverState *bs,
case QCOW2_CLUSTER_NORMAL:
child = s->data_file;
copy_offset += offset_into_cluster(s, src_offset);
- if ((copy_offset & 511) != 0) {
+ if (!QEMU_IS_ALIGNED(copy_offset, BDRV_SECTOR_SIZE)) {
ret = -EIO;
goto out;
}
@@ -3958,8 +3959,9 @@ static int coroutine_fn
qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
return -ENOTSUP;
}
- if (offset & 511) {
- error_setg(errp, "The new size must be a multiple of 512");
+ if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) {
+ error_setg(errp, "The new size must be a multiple of %u",
+ (unsigned) BDRV_SECTOR_SIZE);
return -EINVAL;
}
--
2.20.1
- Re: [PATCH v2 3/4] qcow2: Tighten cluster_offset alignment assertions, (continued)
- [PATCH v2 1/4] qcow2: Require that the virtual size is a multiple of the sector size, Alberto Garcia, 2020/01/09
- Re: [PATCH v2 1/4] qcow2: Require that the virtual size is a multiple of the sector size, Max Reitz, 2020/01/14
- Re: [PATCH v2 1/4] qcow2: Require that the virtual size is a multiple of the sector size, Alberto Garcia, 2020/01/14
- Re: [PATCH v2 1/4] qcow2: Require that the virtual size is a multiple of the sector size, Max Reitz, 2020/01/14
- Re: [PATCH v2 1/4] qcow2: Require that the virtual size is a multiple of the sector size, Alberto Garcia, 2020/01/14
- Re: [PATCH v2 1/4] qcow2: Require that the virtual size is a multiple of the sector size, Max Reitz, 2020/01/14
- Re: [PATCH v2 1/4] qcow2: Require that the virtual size is a multiple of the sector size, Alberto Garcia, 2020/01/16
[PATCH v2 4/4] qcow2: Use BDRV_SECTOR_SIZE instead of the hardcoded value,
Alberto Garcia <=
- Re: [PATCH v2 4/4] qcow2: Use BDRV_SECTOR_SIZE instead of the hardcoded value, Max Reitz, 2020/01/14
- Re: [PATCH v2 4/4] qcow2: Use BDRV_SECTOR_SIZE instead of the hardcoded value, Alberto Garcia, 2020/01/16
- Re: [PATCH v2 4/4] qcow2: Use BDRV_SECTOR_SIZE instead of the hardcoded value, Max Reitz, 2020/01/17
- Re: [PATCH v2 4/4] qcow2: Use BDRV_SECTOR_SIZE instead of the hardcoded value, Kevin Wolf, 2020/01/17
- Re: [PATCH v2 4/4] qcow2: Use BDRV_SECTOR_SIZE instead of the hardcoded value, Max Reitz, 2020/01/17
- Re: [PATCH v2 4/4] qcow2: Use BDRV_SECTOR_SIZE instead of the hardcoded value, Kevin Wolf, 2020/01/17
- Re: [PATCH v2 4/4] qcow2: Use BDRV_SECTOR_SIZE instead of the hardcoded value, Alberto Garcia, 2020/01/17
Re: [PATCH v2 4/4] qcow2: Use BDRV_SECTOR_SIZE instead of the hardcoded value, Alberto Garcia, 2020/01/18
[PATCH v2 2/4] qcow2: Don't round the L1 table allocation up to the sector size, Alberto Garcia, 2020/01/09