]> Git Repo - qemu.git/commitdiff
replication: Fix replication open fail
authorWang Guang <[email protected]>
Wed, 25 Oct 2017 06:51:23 +0000 (14:51 +0800)
committerKevin Wolf <[email protected]>
Fri, 17 Nov 2017 12:35:59 +0000 (13:35 +0100)
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]>
block/replication.c

index 3a4e6822e430b9220c72f017a6feadfe4e275393..1c95d673ff366d126c49b4077faa9e57989f3ee3 100644 (file)
@@ -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;
 }
 
This page took 0.028313 seconds and 4 git commands to generate.