diff options
author | Wang Guang <wang.guang55@zte.com.cn> | 2017-10-25 14:51:23 +0800 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2017-11-17 13:35:59 +0100 |
commit | 611e0653adfb2765b712ad8bd312f2fd9765d13c (patch) | |
tree | fe6943e7a03a4b1f43614e225507c3fa6b56418e /block/replication.c | |
parent | fec035a53fa15c4c8c4e62bfef56a35df4161e38 (diff) |
replication: Fix replication open fail
replication_child_perm request write
permissions for all child which will lead bdrv_check_perm fail.
replication_child_perm() should request write
permissions only if it is writable itself.
Signed-off-by: Wang Guang <wang.guang55@zte.com.cn>
Signed-off-by: Wang Yong <wang.yong155@zte.com.cn>
Reviewed-by: Xie Changlong <xiechanglong@cmss.chinamobile.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/replication.c')
-rw-r--r-- | block/replication.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/block/replication.c b/block/replication.c index 3a4e6822e4..1c95d673ff 100644 --- a/block/replication.c +++ b/block/replication.c @@ -161,10 +161,13 @@ static void replication_child_perm(BlockDriverState *bs, BdrvChild *c, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { - *nperm = *nshared = BLK_PERM_CONSISTENT_READ \ - | BLK_PERM_WRITE \ - | BLK_PERM_WRITE_UNCHANGED; - + *nperm = BLK_PERM_CONSISTENT_READ; + if ((bs->open_flags & (BDRV_O_INACTIVE | BDRV_O_RDWR)) == BDRV_O_RDWR) { + *nperm |= BLK_PERM_WRITE; + } + *nshared = BLK_PERM_CONSISTENT_READ \ + | BLK_PERM_WRITE \ + | BLK_PERM_WRITE_UNCHANGED; return; } |