[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 05/12] raw_bsd: don't check size alignment when only
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 05/12] raw_bsd: don't check size alignment when only offset is set |
Date: |
Fri, 11 Nov 2016 17:55:04 +0100 |
From: Tomáš Golembiovský <address@hidden>
We make sure that the size is aligned to sector length to prevent any
round ups. Otherwise we could end up reading/writing data outside the
area specified by user. This is only needed when user supplies the size
option to avoid any surprises. It is not necessary when only offset is
set.
More over, the check made it difficult to use the offset option without
size option. The check puts unneeded restriction on the offset which had
to be aligned too. Because bdrv_getlength() returns aligned value having
unaligned offset would make the check fail.
Signed-off-by: Tomáš Golembiovský <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/raw_bsd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/raw_bsd.c b/block/raw_bsd.c
index cf7a560..8a5b9b0 100644
--- a/block/raw_bsd.c
+++ b/block/raw_bsd.c
@@ -119,7 +119,7 @@ static int raw_read_options(QDict *options,
BlockDriverState *bs,
/* Make sure size is multiple of BDRV_SECTOR_SIZE to prevent rounding
* up and leaking out of the specified area. */
- if (!QEMU_IS_ALIGNED(s->size, BDRV_SECTOR_SIZE)) {
+ if (s->has_size && !QEMU_IS_ALIGNED(s->size, BDRV_SECTOR_SIZE)) {
error_setg(errp, "Specified size is not multiple of %llu",
BDRV_SECTOR_SIZE);
ret = -EINVAL;
--
1.8.3.1
- [Qemu-block] [PULL 00/12] Block layer patches for 2.8.0-rc0, Kevin Wolf, 2016/11/11
- [Qemu-block] [PULL 01/12] block/nbd: Fix the leaked visitor, Kevin Wolf, 2016/11/11
- [Qemu-block] [PULL 02/12] block/ssh: Code cleanup for unused parameter, Kevin Wolf, 2016/11/11
- [Qemu-block] [PULL 03/12] hmp: Make block_stream set an explicit job ID, Kevin Wolf, 2016/11/11
- [Qemu-block] [PULL 04/12] raw_bsd: move check to prevent overflow, Kevin Wolf, 2016/11/11
- [Qemu-block] [PULL 05/12] raw_bsd: don't check size alignment when only offset is set,
Kevin Wolf <=
- [Qemu-block] [PULL 06/12] qcow2: Remove stale FIXME comment, Kevin Wolf, 2016/11/11
- [Qemu-block] [PULL 07/12] nfs: Fix memory leak in nfs_file_create(), Kevin Wolf, 2016/11/11
- [Qemu-block] [PULL 08/12] block: Fix bdrv_iterate_format() sorting, Kevin Wolf, 2016/11/11
- [Qemu-block] [PULL 09/12] block: Emit modules in bdrv_iterate_format(), Kevin Wolf, 2016/11/11
- [Qemu-block] [PULL 11/12] iotests: Always use -machine accel=qtest, Kevin Wolf, 2016/11/11
- [Qemu-block] [PULL 10/12] iotests: Skip test 162 if there is no SSH support, Kevin Wolf, 2016/11/11
- [Qemu-block] [PULL 12/12] raw-posix: Rename 'raw_s' to 'rs', Kevin Wolf, 2016/11/11