qemu-devel
[Top][All Lists]
Advanced

[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);
>  
> 


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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