Commit 69dca43d authored by Max Reitz's avatar Max Reitz Committed by Kevin Wolf
Browse files

block: Use bdrv_default_perms()



bdrv_default_perms() can decide which permission profile to use based on
the BdrvChildRole, so block drivers do not need to select it explicitly.

The blkverify driver now no longer shares the WRITE permission for the
image to verify.  We thus have to adjust two places in
test-block-iothread not to take it.  (Note that in theory, blkverify
should behave like quorum in this regard and share neither WRITE nor
RESIZE for both of its children.  In practice, it does not really
matter, because blkverify is used only for debugging, so we might as
well keep its permissions rather liberal.)

Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Message-Id: <20200513110544.176672-30-mreitz@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent a16be3cd
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ static void backup_top_child_perm(BlockDriverState *bs, BdrvChild *c,
        *nperm = BLK_PERM_WRITE;
    } else {
        /* Source child */
        bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue,
        bdrv_default_perms(bs, c, child_class, role, reopen_queue,
                           perm, shared, nperm, nshared);

        if (perm & BLK_PERM_WRITE) {
+2 −2
Original line number Diff line number Diff line
@@ -1003,7 +1003,7 @@ static void blkdebug_child_perm(BlockDriverState *bs, BdrvChild *c,
{
    BDRVBlkdebugState *s = bs->opaque;

    bdrv_filter_default_perms(bs, c, child_class, role, reopen_queue,
    bdrv_default_perms(bs, c, child_class, role, reopen_queue,
                       perm, shared, nperm, nshared);

    *nperm |= s->take_child_perms;
+2 −7
Original line number Diff line number Diff line
@@ -295,13 +295,8 @@ static void blk_log_writes_child_perm(BlockDriverState *bs, BdrvChild *c,
        return;
    }

    if (!strcmp(c->name, "log")) {
        bdrv_format_default_perms(bs, c, child_class, role, ro_q, perm, shrd,
    bdrv_default_perms(bs, c, child_class, role, ro_q, perm, shrd,
                       nperm, nshrd);
    } else {
        bdrv_filter_default_perms(bs, c, child_class, role, ro_q, perm, shrd,
                                  nperm, nshrd);
    }
}

static void blk_log_writes_refresh_limits(BlockDriverState *bs, Error **errp)
+1 −1
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ static BlockDriver bdrv_blkreplay = {
    .is_filter              = true,

    .bdrv_open              = blkreplay_open,
    .bdrv_child_perm        = bdrv_filter_default_perms,
    .bdrv_child_perm        = bdrv_default_perms,
    .bdrv_getlength         = blkreplay_getlength,

    .bdrv_co_preadv         = blkreplay_co_preadv,
+1 −1
Original line number Diff line number Diff line
@@ -319,7 +319,7 @@ static BlockDriver bdrv_blkverify = {
    .bdrv_parse_filename              = blkverify_parse_filename,
    .bdrv_file_open                   = blkverify_open,
    .bdrv_close                       = blkverify_close,
    .bdrv_child_perm                  = bdrv_filter_default_perms,
    .bdrv_child_perm                  = bdrv_default_perms,
    .bdrv_getlength                   = blkverify_getlength,
    .bdrv_refresh_filename            = blkverify_refresh_filename,
    .bdrv_dirname                     = blkverify_dirname,
Loading