Commit 80a15e3e authored by Tomáš Golembiovský's avatar Tomáš Golembiovský Committed by Kevin Wolf
Browse files

raw_bsd: don't check size alignment when only offset is set



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: default avatarTomáš Golembiovský <tgolembi@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent 40332872
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;