From e0995dc3da0894d0a8260bddaa200a4cd7809ba4 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Thu, 14 Sep 2017 12:47:11 +0200 Subject: block: Add reopen_queue to bdrv_child_perm() In the context of bdrv_reopen(), we'll have to look at the state of the graph as it will be after the reopen. This interface addition is in preparation for the change. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- include/block/block_int.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/block/block_int.h b/include/block/block_int.h index ba4c383393..99abe2ce74 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -411,9 +411,14 @@ struct BlockDriver { * * If @c is NULL, return the permissions for attaching a new child for the * given @role. + * + * If @reopen_queue is non-NULL, don't return the currently needed + * permissions, but those that will be needed after applying the + * @reopen_queue. */ void (*bdrv_child_perm)(BlockDriverState *bs, BdrvChild *c, const BdrvChildRole *role, + BlockReopenQueue *reopen_queue, uint64_t parent_perm, uint64_t parent_shared, uint64_t *nperm, uint64_t *nshared); @@ -983,6 +988,7 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared, * all children */ void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c, const BdrvChildRole *role, + BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared); @@ -992,6 +998,7 @@ void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c, * CONSISTENT_READ and doesn't share WRITE. */ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, const BdrvChildRole *role, + BlockReopenQueue *reopen_queue, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared); -- cgit v1.2.3 From 148eb13c84cccd0eedd6e59f90e0151bd7bac9fa Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Thu, 14 Sep 2017 14:32:04 +0200 Subject: block: Base permissions on rw state after reopen When new permissions are calculated during bdrv_reopen(), they need to be based on the state of the graph as it will be after the reopen has completed, not on the current state of the involved nodes. This patch makes bdrv_is_writable() optionally accept a BlockReopenQueue from which the new flags are taken. This is then used for determining the new bs->file permissions of format drivers as soon as we add the code to actually pass a non-NULL reopen queue to the .bdrv_child_perm callbacks. While moving bdrv_is_writable(), make it static. It isn't used outside block.c. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- include/block/block.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/block/block.h b/include/block/block.h index 2ad18775af..082eb2cd9c 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -435,7 +435,6 @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base, int64_t offset, int64_t bytes, int64_t *pnum); bool bdrv_is_read_only(BlockDriverState *bs); -bool bdrv_is_writable(BlockDriverState *bs); int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, bool ignore_allow_rdw, Error **errp); int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp); -- cgit v1.2.3 From 3045025991ebeec77ce89c8ec56e83858950bbb3 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Mon, 3 Jul 2017 17:07:35 +0200 Subject: block: Fix permissions after bdrv_reopen() If we switch between read-only and read-write, the permissions that image format drivers need on bs->file change, too. Make sure to update the permissions during bdrv_reopen(). Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- include/block/block.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/block/block.h b/include/block/block.h index 082eb2cd9c..3c3af462e4 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -166,6 +166,7 @@ typedef QSIMPLEQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) BlockReopenQueue; typedef struct BDRVReopenState { BlockDriverState *bs; int flags; + uint64_t perm, shared_perm; QDict *options; QDict *explicit_options; void *opaque; -- cgit v1.2.3