[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 51/54] block: Assertions for write permissions
From: |
Max Reitz |
Subject: |
Re: [Qemu-devel] [PATCH 51/54] block: Assertions for write permissions |
Date: |
Sat, 25 Feb 2017 16:13:55 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
On 21.02.2017 15:58, Kevin Wolf wrote:
> This adds assertions that ensure that the necessary write permissions
> have been granted before someone attempts to write to a node.
>
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
> block/io.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/block/io.c b/block/io.c
> index 63e4400..4c79745 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -925,9 +925,11 @@ bdrv_driver_pwritev_compressed(BlockDriverState *bs,
> uint64_t offset,
> return drv->bdrv_co_pwritev_compressed(bs, offset, bytes, qiov);
> }
>
> -static int coroutine_fn bdrv_co_do_copy_on_readv(BlockDriverState *bs,
> +static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child,
> int64_t offset, unsigned int bytes, QEMUIOVector *qiov)
> {
> + BlockDriverState *bs = child->bs;
> +
> /* Perform I/O through a temporary buffer so that users who scribble over
> * their read buffer while the operation is in progress do not end up
> * modifying the image file. This is critical for zero-copy guest I/O
As I said, I think this hunk needs to be in the previous patch.
Max
> @@ -943,6 +945,8 @@ static int coroutine_fn
> bdrv_co_do_copy_on_readv(BlockDriverState *bs,
> size_t skip_bytes;
> int ret;
>
> + assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE));
> +
> /* Cover entire cluster so no additional backing file I/O is required
> when
> * allocating cluster in the image file.
> */
> @@ -1051,7 +1055,7 @@ static int coroutine_fn bdrv_aligned_preadv(BdrvChild
> *child,
> }
>
> if (!ret || pnum != nb_sectors) {
> - ret = bdrv_co_do_copy_on_readv(bs, offset, bytes, qiov);
> + ret = bdrv_co_do_copy_on_readv(child, offset, bytes, qiov);
> goto out;
> }
> }
> @@ -1334,6 +1338,7 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild
> *child,
> assert(!waited || !req->serialising);
> assert(req->overlap_offset <= offset);
> assert(offset + bytes <= req->overlap_offset + req->overlap_bytes);
> + assert(child->perm & BLK_PERM_WRITE);
>
> ret = notifier_with_return_list_notify(&bs->before_write_notifiers, req);
>
>
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH 43/54] stream: Use real permissions in streaming block job, (continued)
- [Qemu-devel] [PATCH 42/54] mirror: Use real permissions in mirror/active commit block job, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 46/54] hmp: Request permissions in qemu-io, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 45/54] commit: Add filter-node-name to block-commit, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 49/54] tests: Remove FIXME comments, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 51/54] block: Assertions for write permissions, Kevin Wolf, 2017/02/21
- Re: [Qemu-devel] [PATCH 51/54] block: Assertions for write permissions,
Max Reitz <=
- [Qemu-devel] [PATCH 47/54] migration/block: Use real permissions, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 50/54] block: Pass BdrvChild to bdrv_aligned_preadv/pwritev, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 48/54] nbd/server: Use real permissions for NBD exports, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 52/54] block: Assertions for resize permission, Kevin Wolf, 2017/02/21
- [Qemu-devel] [PATCH 53/54] block: Add Error parameter to bdrv_set_backing_hd(), Kevin Wolf, 2017/02/21