aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2017-05-03 00:35:38 +0800
committerKevin Wolf <kwolf@redhat.com>2017-05-11 11:02:38 +0200
commitffd1a5a25c7199d3c9c6d84a5a84ae51f8824602 (patch)
tree17e4b42cf5a589efb7add93a4ac785a8c1952935 /block.c
parent5a9347c6730ff6d68bba30b24f80cd90a6671a20 (diff)
block: Respect "force-share" in perm propagating
Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/block.c b/block.c
index 31d6d0be34..1e00e313c3 100644
--- a/block.c
+++ b/block.c
@@ -1465,6 +1465,22 @@ static int bdrv_child_check_perm(BdrvChild *c, uint64_t perm, uint64_t shared,
static void bdrv_child_abort_perm_update(BdrvChild *c);
static void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shared);
+static void bdrv_child_perm(BlockDriverState *bs, BlockDriverState *child_bs,
+ BdrvChild *c,
+ const BdrvChildRole *role,
+ uint64_t parent_perm, uint64_t parent_shared,
+ uint64_t *nperm, uint64_t *nshared)
+{
+ if (bs->drv && bs->drv->bdrv_child_perm) {
+ bs->drv->bdrv_child_perm(bs, c, role,
+ parent_perm, parent_shared,
+ nperm, nshared);
+ }
+ if (child_bs && child_bs->force_share) {
+ *nshared = BLK_PERM_ALL;
+ }
+}
+
/*
* Check whether permissions on this node can be changed in a way that
* @cumulative_perms and @cumulative_shared_perms are the new cumulative
@@ -1509,9 +1525,9 @@ static int bdrv_check_perm(BlockDriverState *bs, uint64_t cumulative_perms,
/* Check all children */
QLIST_FOREACH(c, &bs->children, next) {
uint64_t cur_perm, cur_shared;
- drv->bdrv_child_perm(bs, c, c->role,
- cumulative_perms, cumulative_shared_perms,
- &cur_perm, &cur_shared);
+ bdrv_child_perm(bs, c->bs, c, c->role,
+ cumulative_perms, cumulative_shared_perms,
+ &cur_perm, &cur_shared);
ret = bdrv_child_check_perm(c, cur_perm, cur_shared, ignore_children,
errp);
if (ret < 0) {
@@ -1571,9 +1587,9 @@ static void bdrv_set_perm(BlockDriverState *bs, uint64_t cumulative_perms,
/* Update all children */
QLIST_FOREACH(c, &bs->children, next) {
uint64_t cur_perm, cur_shared;
- drv->bdrv_child_perm(bs, c, c->role,
- cumulative_perms, cumulative_shared_perms,
- &cur_perm, &cur_shared);
+ bdrv_child_perm(bs, c->bs, c, c->role,
+ cumulative_perms, cumulative_shared_perms,
+ &cur_perm, &cur_shared);
bdrv_child_set_perm(c, cur_perm, cur_shared);
}
}
@@ -1908,8 +1924,8 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
assert(parent_bs->drv);
assert(bdrv_get_aio_context(parent_bs) == bdrv_get_aio_context(child_bs));
- parent_bs->drv->bdrv_child_perm(parent_bs, NULL, child_role,
- perm, shared_perm, &perm, &shared_perm);
+ bdrv_child_perm(parent_bs, child_bs, NULL, child_role,
+ perm, shared_perm, &perm, &shared_perm);
child = bdrv_root_attach_child(child_bs, child_name, child_role,
perm, shared_perm, parent_bs, errp);