block: Pass BdrvChildRole to bdrv_child_perm()
For now, all callers pass 0 and no callee evaluates this value. Later patches will change both. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20200513110544.176672-7-mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
258b776515
commit
bf8e925eb5
22
block.c
22
block.c
@ -1954,12 +1954,12 @@ bool bdrv_is_writable(BlockDriverState *bs)
|
|||||||
|
|
||||||
static void bdrv_child_perm(BlockDriverState *bs, BlockDriverState *child_bs,
|
static void bdrv_child_perm(BlockDriverState *bs, BlockDriverState *child_bs,
|
||||||
BdrvChild *c, const BdrvChildClass *child_class,
|
BdrvChild *c, const BdrvChildClass *child_class,
|
||||||
BlockReopenQueue *reopen_queue,
|
BdrvChildRole role, BlockReopenQueue *reopen_queue,
|
||||||
uint64_t parent_perm, uint64_t parent_shared,
|
uint64_t parent_perm, uint64_t parent_shared,
|
||||||
uint64_t *nperm, uint64_t *nshared)
|
uint64_t *nperm, uint64_t *nshared)
|
||||||
{
|
{
|
||||||
assert(bs->drv && bs->drv->bdrv_child_perm);
|
assert(bs->drv && bs->drv->bdrv_child_perm);
|
||||||
bs->drv->bdrv_child_perm(bs, c, child_class, reopen_queue,
|
bs->drv->bdrv_child_perm(bs, c, child_class, role, reopen_queue,
|
||||||
parent_perm, parent_shared,
|
parent_perm, parent_shared,
|
||||||
nperm, nshared);
|
nperm, nshared);
|
||||||
/* TODO Take force_share from reopen_queue */
|
/* TODO Take force_share from reopen_queue */
|
||||||
@ -2053,7 +2053,7 @@ static int bdrv_check_perm(BlockDriverState *bs, BlockReopenQueue *q,
|
|||||||
uint64_t cur_perm, cur_shared;
|
uint64_t cur_perm, cur_shared;
|
||||||
bool child_tighten_restr;
|
bool child_tighten_restr;
|
||||||
|
|
||||||
bdrv_child_perm(bs, c->bs, c, c->klass, q,
|
bdrv_child_perm(bs, c->bs, c, c->klass, c->role, q,
|
||||||
cumulative_perms, cumulative_shared_perms,
|
cumulative_perms, cumulative_shared_perms,
|
||||||
&cur_perm, &cur_shared);
|
&cur_perm, &cur_shared);
|
||||||
ret = bdrv_child_check_perm(c, q, cur_perm, cur_shared, ignore_children,
|
ret = bdrv_child_check_perm(c, q, cur_perm, cur_shared, ignore_children,
|
||||||
@ -2120,7 +2120,7 @@ static void bdrv_set_perm(BlockDriverState *bs, uint64_t cumulative_perms,
|
|||||||
/* Update all children */
|
/* Update all children */
|
||||||
QLIST_FOREACH(c, &bs->children, next) {
|
QLIST_FOREACH(c, &bs->children, next) {
|
||||||
uint64_t cur_perm, cur_shared;
|
uint64_t cur_perm, cur_shared;
|
||||||
bdrv_child_perm(bs, c->bs, c, c->klass, NULL,
|
bdrv_child_perm(bs, c->bs, c, c->klass, c->role, NULL,
|
||||||
cumulative_perms, cumulative_shared_perms,
|
cumulative_perms, cumulative_shared_perms,
|
||||||
&cur_perm, &cur_shared);
|
&cur_perm, &cur_shared);
|
||||||
bdrv_child_set_perm(c, cur_perm, cur_shared);
|
bdrv_child_set_perm(c, cur_perm, cur_shared);
|
||||||
@ -2348,14 +2348,15 @@ int bdrv_child_refresh_perms(BlockDriverState *bs, BdrvChild *c, Error **errp)
|
|||||||
uint64_t perms, shared;
|
uint64_t perms, shared;
|
||||||
|
|
||||||
bdrv_get_cumulative_perm(bs, &parent_perms, &parent_shared);
|
bdrv_get_cumulative_perm(bs, &parent_perms, &parent_shared);
|
||||||
bdrv_child_perm(bs, c->bs, c, c->klass, NULL, parent_perms, parent_shared,
|
bdrv_child_perm(bs, c->bs, c, c->klass, c->role, NULL,
|
||||||
&perms, &shared);
|
parent_perms, parent_shared, &perms, &shared);
|
||||||
|
|
||||||
return bdrv_child_try_set_perm(c, perms, shared, errp);
|
return bdrv_child_try_set_perm(c, perms, shared, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
|
void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole role,
|
||||||
BlockReopenQueue *reopen_queue,
|
BlockReopenQueue *reopen_queue,
|
||||||
uint64_t perm, uint64_t shared,
|
uint64_t perm, uint64_t shared,
|
||||||
uint64_t *nperm, uint64_t *nshared)
|
uint64_t *nperm, uint64_t *nshared)
|
||||||
@ -2366,6 +2367,7 @@ void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
|
|||||||
|
|
||||||
void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
|
void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole role,
|
||||||
BlockReopenQueue *reopen_queue,
|
BlockReopenQueue *reopen_queue,
|
||||||
uint64_t perm, uint64_t shared,
|
uint64_t perm, uint64_t shared,
|
||||||
uint64_t *nperm, uint64_t *nshared)
|
uint64_t *nperm, uint64_t *nshared)
|
||||||
@ -2378,7 +2380,7 @@ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
|
|||||||
|
|
||||||
/* Apart from the modifications below, the same permissions are
|
/* Apart from the modifications below, the same permissions are
|
||||||
* forwarded and left alone as for filters */
|
* forwarded and left alone as for filters */
|
||||||
bdrv_filter_default_perms(bs, c, child_class, reopen_queue,
|
bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue,
|
||||||
perm, shared, &perm, &shared);
|
perm, shared, &perm, &shared);
|
||||||
|
|
||||||
/* Format drivers may touch metadata even if the guest doesn't write */
|
/* Format drivers may touch metadata even if the guest doesn't write */
|
||||||
@ -2655,7 +2657,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
|
|||||||
bdrv_get_cumulative_perm(parent_bs, &perm, &shared_perm);
|
bdrv_get_cumulative_perm(parent_bs, &perm, &shared_perm);
|
||||||
|
|
||||||
assert(parent_bs->drv);
|
assert(parent_bs->drv);
|
||||||
bdrv_child_perm(parent_bs, child_bs, NULL, child_class, NULL,
|
bdrv_child_perm(parent_bs, child_bs, NULL, child_class, child_role, NULL,
|
||||||
perm, shared_perm, &perm, &shared_perm);
|
perm, shared_perm, &perm, &shared_perm);
|
||||||
|
|
||||||
child = bdrv_root_attach_child(child_bs, child_name, child_class,
|
child = bdrv_root_attach_child(child_bs, child_name, child_class,
|
||||||
@ -3683,7 +3685,7 @@ int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp)
|
|||||||
if (state->replace_backing_bs && state->new_backing_bs) {
|
if (state->replace_backing_bs && state->new_backing_bs) {
|
||||||
uint64_t nperm, nshared;
|
uint64_t nperm, nshared;
|
||||||
bdrv_child_perm(state->bs, state->new_backing_bs,
|
bdrv_child_perm(state->bs, state->new_backing_bs,
|
||||||
NULL, &child_backing, bs_queue,
|
NULL, &child_backing, 0, bs_queue,
|
||||||
state->perm, state->shared_perm,
|
state->perm, state->shared_perm,
|
||||||
&nperm, &nshared);
|
&nperm, &nshared);
|
||||||
ret = bdrv_check_update_perm(state->new_backing_bs, NULL,
|
ret = bdrv_check_update_perm(state->new_backing_bs, NULL,
|
||||||
@ -3806,7 +3808,7 @@ static void bdrv_reopen_perm(BlockReopenQueue *q, BlockDriverState *bs,
|
|||||||
} else {
|
} else {
|
||||||
uint64_t nperm, nshared;
|
uint64_t nperm, nshared;
|
||||||
|
|
||||||
bdrv_child_perm(parent->state.bs, bs, c, c->klass, q,
|
bdrv_child_perm(parent->state.bs, bs, c, c->klass, c->role, q,
|
||||||
parent->state.perm, parent->state.shared_perm,
|
parent->state.perm, parent->state.shared_perm,
|
||||||
&nperm, &nshared);
|
&nperm, &nshared);
|
||||||
|
|
||||||
|
@ -123,6 +123,7 @@ static void backup_top_refresh_filename(BlockDriverState *bs)
|
|||||||
|
|
||||||
static void backup_top_child_perm(BlockDriverState *bs, BdrvChild *c,
|
static void backup_top_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole role,
|
||||||
BlockReopenQueue *reopen_queue,
|
BlockReopenQueue *reopen_queue,
|
||||||
uint64_t perm, uint64_t shared,
|
uint64_t perm, uint64_t shared,
|
||||||
uint64_t *nperm, uint64_t *nshared)
|
uint64_t *nperm, uint64_t *nshared)
|
||||||
@ -155,7 +156,7 @@ static void backup_top_child_perm(BlockDriverState *bs, BdrvChild *c,
|
|||||||
*nperm = BLK_PERM_WRITE;
|
*nperm = BLK_PERM_WRITE;
|
||||||
} else {
|
} else {
|
||||||
/* Source child */
|
/* Source child */
|
||||||
bdrv_filter_default_perms(bs, c, child_class, reopen_queue,
|
bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue,
|
||||||
perm, shared, nperm, nshared);
|
perm, shared, nperm, nshared);
|
||||||
|
|
||||||
if (perm & BLK_PERM_WRITE) {
|
if (perm & BLK_PERM_WRITE) {
|
||||||
|
@ -994,14 +994,15 @@ static int blkdebug_reopen_prepare(BDRVReopenState *reopen_state,
|
|||||||
|
|
||||||
static void blkdebug_child_perm(BlockDriverState *bs, BdrvChild *c,
|
static void blkdebug_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole role,
|
||||||
BlockReopenQueue *reopen_queue,
|
BlockReopenQueue *reopen_queue,
|
||||||
uint64_t perm, uint64_t shared,
|
uint64_t perm, uint64_t shared,
|
||||||
uint64_t *nperm, uint64_t *nshared)
|
uint64_t *nperm, uint64_t *nshared)
|
||||||
{
|
{
|
||||||
BDRVBlkdebugState *s = bs->opaque;
|
BDRVBlkdebugState *s = bs->opaque;
|
||||||
|
|
||||||
bdrv_filter_default_perms(bs, c, child_class, reopen_queue, perm, shared,
|
bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue,
|
||||||
nperm, nshared);
|
perm, shared, nperm, nshared);
|
||||||
|
|
||||||
*nperm |= s->take_child_perms;
|
*nperm |= s->take_child_perms;
|
||||||
*nshared &= ~s->unshare_child_perms;
|
*nshared &= ~s->unshare_child_perms;
|
||||||
|
@ -283,6 +283,7 @@ static int64_t blk_log_writes_getlength(BlockDriverState *bs)
|
|||||||
|
|
||||||
static void blk_log_writes_child_perm(BlockDriverState *bs, BdrvChild *c,
|
static void blk_log_writes_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole role,
|
||||||
BlockReopenQueue *ro_q,
|
BlockReopenQueue *ro_q,
|
||||||
uint64_t perm, uint64_t shrd,
|
uint64_t perm, uint64_t shrd,
|
||||||
uint64_t *nperm, uint64_t *nshrd)
|
uint64_t *nperm, uint64_t *nshrd)
|
||||||
@ -294,11 +295,11 @@ static void blk_log_writes_child_perm(BlockDriverState *bs, BdrvChild *c,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(c->name, "log")) {
|
if (!strcmp(c->name, "log")) {
|
||||||
bdrv_format_default_perms(bs, c, child_class, ro_q, perm, shrd, nperm,
|
bdrv_format_default_perms(bs, c, child_class, role, ro_q, perm, shrd,
|
||||||
nshrd);
|
nperm, nshrd);
|
||||||
} else {
|
} else {
|
||||||
bdrv_filter_default_perms(bs, c, child_class, ro_q, perm, shrd, nperm,
|
bdrv_filter_default_perms(bs, c, child_class, role, ro_q, perm, shrd,
|
||||||
nshrd);
|
nperm, nshrd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,6 +224,7 @@ static void bdrv_commit_top_refresh_filename(BlockDriverState *bs)
|
|||||||
|
|
||||||
static void bdrv_commit_top_child_perm(BlockDriverState *bs, BdrvChild *c,
|
static void bdrv_commit_top_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole role,
|
||||||
BlockReopenQueue *reopen_queue,
|
BlockReopenQueue *reopen_queue,
|
||||||
uint64_t perm, uint64_t shared,
|
uint64_t perm, uint64_t shared,
|
||||||
uint64_t *nperm, uint64_t *nshared)
|
uint64_t *nperm, uint64_t *nshared)
|
||||||
|
@ -52,6 +52,7 @@ static int cor_open(BlockDriverState *bs, QDict *options, int flags,
|
|||||||
|
|
||||||
static void cor_child_perm(BlockDriverState *bs, BdrvChild *c,
|
static void cor_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole role,
|
||||||
BlockReopenQueue *reopen_queue,
|
BlockReopenQueue *reopen_queue,
|
||||||
uint64_t perm, uint64_t shared,
|
uint64_t perm, uint64_t shared,
|
||||||
uint64_t *nperm, uint64_t *nshared)
|
uint64_t *nperm, uint64_t *nshared)
|
||||||
|
@ -1493,6 +1493,7 @@ static void bdrv_mirror_top_refresh_filename(BlockDriverState *bs)
|
|||||||
|
|
||||||
static void bdrv_mirror_top_child_perm(BlockDriverState *bs, BdrvChild *c,
|
static void bdrv_mirror_top_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole role,
|
||||||
BlockReopenQueue *reopen_queue,
|
BlockReopenQueue *reopen_queue,
|
||||||
uint64_t perm, uint64_t shared,
|
uint64_t perm, uint64_t shared,
|
||||||
uint64_t *nperm, uint64_t *nshared)
|
uint64_t *nperm, uint64_t *nshared)
|
||||||
|
@ -1152,6 +1152,7 @@ static char *quorum_dirname(BlockDriverState *bs, Error **errp)
|
|||||||
|
|
||||||
static void quorum_child_perm(BlockDriverState *bs, BdrvChild *c,
|
static void quorum_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole role,
|
||||||
BlockReopenQueue *reopen_queue,
|
BlockReopenQueue *reopen_queue,
|
||||||
uint64_t perm, uint64_t shared,
|
uint64_t perm, uint64_t shared,
|
||||||
uint64_t *nperm, uint64_t *nshared)
|
uint64_t *nperm, uint64_t *nshared)
|
||||||
|
@ -164,6 +164,7 @@ static void replication_close(BlockDriverState *bs)
|
|||||||
|
|
||||||
static void replication_child_perm(BlockDriverState *bs, BdrvChild *c,
|
static void replication_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole role,
|
||||||
BlockReopenQueue *reopen_queue,
|
BlockReopenQueue *reopen_queue,
|
||||||
uint64_t perm, uint64_t shared,
|
uint64_t perm, uint64_t shared,
|
||||||
uint64_t *nperm, uint64_t *nshared)
|
uint64_t *nperm, uint64_t *nshared)
|
||||||
|
@ -3211,6 +3211,7 @@ err:
|
|||||||
|
|
||||||
static void vvfat_child_perm(BlockDriverState *bs, BdrvChild *c,
|
static void vvfat_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole role,
|
||||||
BlockReopenQueue *reopen_queue,
|
BlockReopenQueue *reopen_queue,
|
||||||
uint64_t perm, uint64_t shared,
|
uint64_t perm, uint64_t shared,
|
||||||
uint64_t *nperm, uint64_t *nshared)
|
uint64_t *nperm, uint64_t *nshared)
|
||||||
|
@ -556,7 +556,7 @@ struct BlockDriver {
|
|||||||
* the parents in @parent_perm and @parent_shared.
|
* the parents in @parent_perm and @parent_shared.
|
||||||
*
|
*
|
||||||
* If @c is NULL, return the permissions for attaching a new child for the
|
* If @c is NULL, return the permissions for attaching a new child for the
|
||||||
* given @child_class.
|
* given @child_class and @role.
|
||||||
*
|
*
|
||||||
* If @reopen_queue is non-NULL, don't return the currently needed
|
* If @reopen_queue is non-NULL, don't return the currently needed
|
||||||
* permissions, but those that will be needed after applying the
|
* permissions, but those that will be needed after applying the
|
||||||
@ -564,6 +564,7 @@ struct BlockDriver {
|
|||||||
*/
|
*/
|
||||||
void (*bdrv_child_perm)(BlockDriverState *bs, BdrvChild *c,
|
void (*bdrv_child_perm)(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole role,
|
||||||
BlockReopenQueue *reopen_queue,
|
BlockReopenQueue *reopen_queue,
|
||||||
uint64_t parent_perm, uint64_t parent_shared,
|
uint64_t parent_perm, uint64_t parent_shared,
|
||||||
uint64_t *nperm, uint64_t *nshared);
|
uint64_t *nperm, uint64_t *nshared);
|
||||||
@ -1266,6 +1267,7 @@ int bdrv_child_refresh_perms(BlockDriverState *bs, BdrvChild *c, Error **errp);
|
|||||||
* all children */
|
* all children */
|
||||||
void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
|
void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole child_role,
|
||||||
BlockReopenQueue *reopen_queue,
|
BlockReopenQueue *reopen_queue,
|
||||||
uint64_t perm, uint64_t shared,
|
uint64_t perm, uint64_t shared,
|
||||||
uint64_t *nperm, uint64_t *nshared);
|
uint64_t *nperm, uint64_t *nshared);
|
||||||
@ -1276,6 +1278,7 @@ void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c,
|
|||||||
* CONSISTENT_READ and doesn't share WRITE. */
|
* CONSISTENT_READ and doesn't share WRITE. */
|
||||||
void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
|
void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole child_role,
|
||||||
BlockReopenQueue *reopen_queue,
|
BlockReopenQueue *reopen_queue,
|
||||||
uint64_t perm, uint64_t shared,
|
uint64_t perm, uint64_t shared,
|
||||||
uint64_t *nperm, uint64_t *nshared);
|
uint64_t *nperm, uint64_t *nshared);
|
||||||
|
@ -87,6 +87,7 @@ static int coroutine_fn bdrv_test_co_preadv(BlockDriverState *bs,
|
|||||||
|
|
||||||
static void bdrv_test_child_perm(BlockDriverState *bs, BdrvChild *c,
|
static void bdrv_test_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole role,
|
||||||
BlockReopenQueue *reopen_queue,
|
BlockReopenQueue *reopen_queue,
|
||||||
uint64_t perm, uint64_t shared,
|
uint64_t perm, uint64_t shared,
|
||||||
uint64_t *nperm, uint64_t *nshared)
|
uint64_t *nperm, uint64_t *nshared)
|
||||||
@ -99,8 +100,8 @@ static void bdrv_test_child_perm(BlockDriverState *bs, BdrvChild *c,
|
|||||||
child_class = &child_file;
|
child_class = &child_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
bdrv_format_default_perms(bs, c, child_class, reopen_queue, perm, shared,
|
bdrv_format_default_perms(bs, c, child_class, role, reopen_queue,
|
||||||
nperm, nshared);
|
perm, shared, nperm, nshared);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bdrv_test_change_backing_file(BlockDriverState *bs,
|
static int bdrv_test_change_backing_file(BlockDriverState *bs,
|
||||||
|
@ -31,6 +31,7 @@ static BlockDriver bdrv_pass_through = {
|
|||||||
|
|
||||||
static void no_perm_default_perms(BlockDriverState *bs, BdrvChild *c,
|
static void no_perm_default_perms(BlockDriverState *bs, BdrvChild *c,
|
||||||
const BdrvChildClass *child_class,
|
const BdrvChildClass *child_class,
|
||||||
|
BdrvChildRole role,
|
||||||
BlockReopenQueue *reopen_queue,
|
BlockReopenQueue *reopen_queue,
|
||||||
uint64_t perm, uint64_t shared,
|
uint64_t perm, uint64_t shared,
|
||||||
uint64_t *nperm, uint64_t *nshared)
|
uint64_t *nperm, uint64_t *nshared)
|
||||||
|
Loading…
Reference in New Issue
Block a user