summary refs log tree commit diff stats
path: root/scripts/qapi/parser.py
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2020-07-16 16:26:00 +0200
committerKevin Wolf <kwolf@redhat.com>2020-07-17 14:20:57 +0200
commit9c60a5d1978e6dcf85c0e01b50e6f7f54ca09104 (patch)
tree7f2c01d09bbc4b01c509cf6b67b271623a8902fc /scripts/qapi/parser.py
parentd047cfa78dc76fb8c7768620106bf1acb7c79797 (diff)
downloadfocaccia-qemu-9c60a5d1978e6dcf85c0e01b50e6f7f54ca09104.tar.gz
focaccia-qemu-9c60a5d1978e6dcf85c0e01b50e6f7f54ca09104.zip
block: Require aligned image size to avoid assertion failure
Unaligned requests will automatically be aligned to bl.request_alignment
and we can't extend write requests to access space beyond the end of the
image without resizing the image, so if we have the WRITE permission,
but not the RESIZE one, it's required that the image size is aligned.

Failing to meet this requirement 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.

Turn this into a graceful error in bdrv_check_perm() so that WRITE
without RESIZE can only be taken if the image size is aligned. If a user
holds both permissions and drops only RESIZE, the function will return
an error, but bdrv_child_try_set_perm() will ignore the failure silently
if permissions are only requested to be relaxed and just keep both
permissions while returning success.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20200716142601.111237-2-kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'scripts/qapi/parser.py')
0 files changed, 0 insertions, 0 deletions