[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [RFC PATCH 17/41] block: Request real permissions in bl
From: |
Max Reitz |
Subject: |
Re: [Qemu-block] [RFC PATCH 17/41] block: Request real permissions in blk_new_open() |
Date: |
Mon, 20 Feb 2017 12:16:10 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
On 13.02.2017 18:22, Kevin Wolf wrote:
> We can figure out the necessary permissions from the flags that the
> caller passed.
>
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
> block/block-backend.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/block/block-backend.c b/block/block-backend.c
> index 1f80854..e10a278 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -160,6 +160,7 @@ BlockBackend *blk_new_open(const char *filename, const
> char *reference,
> {
> BlockBackend *blk;
> BlockDriverState *bs;
> + uint64_t perm;
>
> blk = blk_new(0, BLK_PERM_ALL);
What about this?
Max
> bs = bdrv_open(filename, reference, options, flags, errp);
> @@ -168,9 +169,20 @@ BlockBackend *blk_new_open(const char *filename, const
> char *reference,
> return NULL;
> }
>
> - /* FIXME Use real permissions */
> + /* blk_new_open() is mainly used in .bdrv_create implementations and the
> + * tools where sharing isn't a concern because the BDS stays private, so
> we
> + * just request permission according to the flags.
> + *
> + * The exceptions are xen_disk and blockdev_init(); in these cases, the
> + * caller of blk_new_open() doesn't make use of the permissions, but they
> + * shouldn't hurt either. We can still share everything here because the
> + * guest devices will add their own blockers if they can't share. */
> + perm = BLK_PERM_CONSISTENT_READ;
> + if (flags & BDRV_O_RDWR) {
> + perm |= BLK_PERM_WRITE;
> + }
> blk->root = bdrv_root_attach_child(bs, "root", &child_root,
> - 0, BLK_PERM_ALL, blk, &error_abort);
> + perm, BLK_PERM_ALL, blk,
> &error_abort);
>
> return blk;
> }
>
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-block] [RFC PATCH 11/41] vvfat: Implement .bdrv_child_perm(), (continued)
- [Qemu-block] [RFC PATCH 12/41] block: Require .bdrv_child_perm() with child nodes, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 13/41] block: Request real permissions in bdrv_attach_child(), Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 14/41] block: Add permissions to BlockBackend, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 15/41] block: Add permissions to blk_new(), Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 17/41] block: Request real permissions in blk_new_open(), Kevin Wolf, 2017/02/13
- Re: [Qemu-block] [RFC PATCH 17/41] block: Request real permissions in blk_new_open(),
Max Reitz <=
- [Qemu-block] [RFC PATCH 16/41] block: Add error parameter to blk_insert_bs(), Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 18/41] block: Allow error return in BlockDevOps.change_media_cb(), Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 19/41] hw/block: Request permissions, Kevin Wolf, 2017/02/13