qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-5.1 1/2] block: Require aligned image size to avoid asser


From: Nir Soffer
Subject: Re: [PATCH for-5.1 1/2] block: Require aligned image size to avoid assertion failure
Date: Mon, 13 Jul 2020 19:33:30 +0300

On Fri, Jul 10, 2020 at 5:22 PM Kevin Wolf <kwolf@redhat.com> wrote:
>
> Unaligned requests will automatically be aligned to bl.request_alignment
> and we don't want to extend requests to access space beyond the end of
> the image, so it's required that the image size is aligned.
>
> With write requests, this could cause assertion failures like this if
> RESIZE permissions weren't requested:
>
> qemu-img: block/io.c:1910: bdrv_co_write_req_prepare: Assertion `end_sector 
> <= bs->total_sectors || child->perm & BLK_PERM_RESIZE' failed.
>
> This was e.g. triggered by qemu-img converting to a target image with 4k
> request alignment when the image was only aligned to 512 bytes, but not
> to 4k.

Was it on NFS? Shouldn't this be fix by the next patch then?

>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/block.c b/block.c
> index cc377d7ef3..c635777911 100644
> --- a/block.c
> +++ b/block.c
> @@ -1489,6 +1489,16 @@ static int bdrv_open_driver(BlockDriverState *bs, 
> BlockDriver *drv,
>          return -EINVAL;
>      }
>
> +    /*
> +     * Unaligned requests will automatically be aligned to 
> bl.request_alignment
> +     * and we don't want to extend requests to access space beyond the end of
> +     * the image, so it's required that the image size is aligned.
> +     */
> +    if ((bs->total_sectors * BDRV_SECTOR_SIZE) % bs->bl.request_alignment) {
> +        error_setg(errp, "Image size is not a multiple of request 
> alignment");
> +        return -EINVAL;
> +    }
> +
>      assert(bdrv_opt_mem_align(bs) != 0);
>      assert(bdrv_min_mem_align(bs) != 0);
>      assert(is_power_of_2(bs->bl.request_alignment));
> --
> 2.25.4
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]