summaryrefslogtreecommitdiff
path: root/block/mirror.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2017-03-06 16:03:00 +0100
committerKevin Wolf <kwolf@redhat.com>2017-03-07 14:53:28 +0100
commit0bf74767ff7f0ae23615162807961c5d7e73507c (patch)
tree69561abe6f440469060b87a00d3cb36db85a107c /block/mirror.c
parent7d9fcb391c7898fb1417d84eba41d3d48bd76605 (diff)
downloadqemu-0bf74767ff7f0ae23615162807961c5d7e73507c.tar.gz
mirror: Fix permissions for removing mirror_top_bs
mirror_top_bs takes write permissions on its backing file, which can make it impossible to attach that backing file node to another parent. However, this is exactly what needs to be done in order to remove mirror_top_bs from the backing chain. So give up the write permission first. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block/mirror.c')
-rw-r--r--block/mirror.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/block/mirror.c b/block/mirror.c
index c9185b38a8..001b5f0a15 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -566,8 +566,10 @@ static void mirror_exit(BlockJob *job, void *opaque)
/* Remove the mirror filter driver from the graph. Before this, get rid of
* the blockers on the intermediate nodes so that the resulting state is
- * valid. */
+ * valid. Also give up permissions on mirror_top_bs->backing, which might
+ * block the removal. */
block_job_remove_all_bdrv(job);
+ bdrv_child_set_perm(mirror_top_bs->backing, 0, BLK_PERM_ALL);
bdrv_replace_in_backing_chain(mirror_top_bs, backing_bs(mirror_top_bs));
/* We just changed the BDS the job BB refers to (with either or both of the
@@ -1234,6 +1236,7 @@ fail:
block_job_unref(&s->common);
}
+ bdrv_child_set_perm(mirror_top_bs->backing, 0, BLK_PERM_ALL);
bdrv_replace_in_backing_chain(mirror_top_bs, backing_bs(mirror_top_bs));
}