aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2017-08-03 17:02:57 +0200
committerKevin Wolf <kwolf@redhat.com>2017-08-08 15:19:16 +0200
commit8aecf1d1bd250a7346165de154f5ccc150ad1aa7 (patch)
tree0a78b3d42600e4e1ab90bf21c1f768b8154cef42
parente5e6268348972aaf415d7931bbd808b3fdba6cb1 (diff)
downloadqemu-8aecf1d1bd250a7346165de154f5ccc150ad1aa7.zip
qemu-8aecf1d1bd250a7346165de154f5ccc150ad1aa7.tar.gz
qemu-8aecf1d1bd250a7346165de154f5ccc150ad1aa7.tar.bz2
block: Fix order in bdrv_replace_child()
Commit 8ee03995 refactored the code incorrectly and broke the release of permissions on the old BDS. Instead of changing the permissions to the new required values after removing the old BDS from the list of children, it only re-obtains the permissions it already had. Change the order of operations so that the old BDS is removed again before calculating the new required permissions. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
-rw-r--r--block.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/block.c b/block.c
index ce9cce7..ab908cd 100644
--- a/block.c
+++ b/block.c
@@ -1933,6 +1933,8 @@ static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs)
BlockDriverState *old_bs = child->bs;
uint64_t perm, shared_perm;
+ bdrv_replace_child_noperm(child, new_bs);
+
if (old_bs) {
/* Update permissions for old node. This is guaranteed to succeed
* because we're just taking a parent away, so we're loosening
@@ -1942,8 +1944,6 @@ static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs)
bdrv_set_perm(old_bs, perm, shared_perm);
}
- bdrv_replace_child_noperm(child, new_bs);
-
if (new_bs) {
bdrv_get_cumulative_perm(new_bs, &perm, &shared_perm);
bdrv_set_perm(new_bs, perm, shared_perm);