[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH 07/41] block: Default .bdrv_child_perm() for
From: |
Max Reitz |
Subject: |
Re: [Qemu-devel] [RFC PATCH 07/41] block: Default .bdrv_child_perm() for filter drivers |
Date: |
Wed, 15 Feb 2017 18:00:16 +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:
> Most filters need permissions related to read and write for their
> children, but only if the node has a parent that wants to use the same
> operation on the filter. The same is true for resize.
>
> This adds a default implementation that simply forwards all necessary
> permissions to all children of the node and leaves the other permissions
> unchanged.
>
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
> block.c | 24 ++++++++++++++++++++++++
> include/block/block_int.h | 8 ++++++++
> 2 files changed, 32 insertions(+)
>
> diff --git a/block.c b/block.c
> index c27cdce..290768d 100644
> --- a/block.c
> +++ b/block.c
> @@ -1436,6 +1436,30 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t
> perm, uint64_t shared,
> return 0;
> }
>
> +#define DEFAULT_PERM_PASSTHROUGH (BLK_PERM_CONSISTENT_READ \
> + | BLK_PERM_WRITE \
> + | BLK_PERM_WRITE_UNCHANGED \
> + | BLK_PERM_RESIZE)
> +#define DEFAULT_PERM_UNCHANGED (BLK_PERM_ALL & ~DEFAULT_PERM_PASSTHROUGH)
> +
> +void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
> + const BdrvChildRole *role,
> + uint64_t perm, uint64_t shared,
> + uint64_t *nperm, uint64_t *nshared)
> +{
> + if (c == NULL) {
> + *nperm = 0;
> + *nshared = BLK_PERM_ALL;
> + return;
> + }
> +
> + *nperm = (perm & DEFAULT_PERM_PASSTHROUGH) |
> + (c->perm & DEFAULT_PERM_UNCHANGED);
> + *nshared = (shared & DEFAULT_PERM_PASSTHROUGH) |
> + (c->shared_perm & DEFAULT_PERM_UNCHANGED);
In my opinion, aligning both equal signs without aligning the ampersands
etc. actually hurts readability. I would not align the equal signs.
Just a stylistic pick, nothing else.
(btw, if it isn't clear: Any patch I'm not replying to looks good to me
-- apart from patch 6 where Fam has already raised the concern I have,
too. I don't give R-bs though because this is still an RFC O:-))
Max
> +}
> +
> +
> static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs)
> {
> BlockDriverState *old_bs = child->bs;
> diff --git a/include/block/block_int.h b/include/block/block_int.h
> index 8578e17..2d74f92 100644
> --- a/include/block/block_int.h
> +++ b/include/block/block_int.h
> @@ -877,6 +877,14 @@ void bdrv_child_set_perm(BdrvChild *c, uint64_t perm,
> uint64_t shared);
> int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared,
> Error **errp);
>
> +/* Default implementation for BlockDriver.bdrv_child_perm() that can be used
> by
> + * block filters: Forward CONSISTENT_READ, WRITE, WRITE_UNCHANGED and RESIZE
> to
> + * all children */
> +void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
> + const BdrvChildRole *role,
> + uint64_t perm, uint64_t shared,
> + uint64_t *nperm, uint64_t *nshared);
> +
>
> const char *bdrv_get_parent_name(const BlockDriverState *bs);
> void blk_dev_change_media_cb(BlockBackend *blk, bool load);
>
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [RFC PATCH 00/41] New op blocker system, Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 02/41] block: Add op blocker permission constants, Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 03/41] block: Add Error argument to bdrv_attach_child(), Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 01/41] block: Attach bs->file only during .bdrv_open(), Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 04/41] block: Let callers request permissions when attaching a child node, Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 05/41] tests: Use opened block node for block job tests, Kevin Wolf, 2017/02/13
- [Qemu-devel] [RFC PATCH 07/41] block: Default .bdrv_child_perm() for filter drivers, Kevin Wolf, 2017/02/13
- Re: [Qemu-devel] [RFC PATCH 07/41] block: Default .bdrv_child_perm() for filter drivers,
Max Reitz <=
- [Qemu-devel] [RFC PATCH 09/41] block: Default .bdrv_child_perm() for format drivers, Kevin Wolf, 2017/02/13
- Re: [Qemu-devel] [RFC PATCH 09/41] block: Default .bdrv_child_perm() for format drivers, Max Reitz, 2017/02/15
[Qemu-devel] [RFC PATCH 06/41] block: Involve block drivers in permission granting, Kevin Wolf, 2017/02/13