Skip to content

Commit

Permalink
replication: Fix replication open fail
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Wang Yong <[email protected]>
Reviewed-by: Xie Changlong <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
wangguang55 authored and kevmw committed Nov 17, 2017
1 parent fec035a commit 611e065
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions block/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 611e065

Please sign in to comment.