summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2017-03-06 13:45:28 +0100
committerKevin Wolf <kwolf@redhat.com>2017-03-07 14:53:28 +0100
commit8ee039951dea9a809e4745c42aebb4a7cec4bbbb (patch)
tree1382d0038ab3b7056e95fe60c84e9842b8a7e57c /block.c
parentd0ac038025bb6e7886c2324258d24e71215b5d35 (diff)
downloadqemu-8ee039951dea9a809e4745c42aebb4a7cec4bbbb.tar.gz
block: Factor out bdrv_replace_child_noperm()
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.c')
-rw-r--r--block.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/block.c b/block.c
index 6dc02b85aa..d4570c85b3 100644
--- a/block.c
+++ b/block.c
@@ -1713,11 +1713,10 @@ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
*nshared = shared;
}
-static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs,
- bool check_new_perm)
+static void bdrv_replace_child_noperm(BdrvChild *child,
+ BlockDriverState *new_bs)
{
BlockDriverState *old_bs = child->bs;
- uint64_t perm, shared_perm;
if (old_bs) {
if (old_bs->quiesce_counter && child->role->drained_end) {
@@ -1727,7 +1726,29 @@ static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs,
child->role->detach(child);
}
QLIST_REMOVE(child, next_parent);
+ }
+
+ child->bs = new_bs;
+
+ if (new_bs) {
+ QLIST_INSERT_HEAD(&new_bs->parents, child, next_parent);
+ if (new_bs->quiesce_counter && child->role->drained_begin) {
+ child->role->drained_begin(child);
+ }
+
+ if (child->role->attach) {
+ child->role->attach(child);
+ }
+ }
+}
+static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs,
+ bool check_new_perm)
+{
+ BlockDriverState *old_bs = child->bs;
+ uint64_t perm, shared_perm;
+
+ 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
* restrictions. */
@@ -1736,23 +1757,14 @@ static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs,
bdrv_set_perm(old_bs, perm, shared_perm);
}
- child->bs = new_bs;
+ bdrv_replace_child_noperm(child, new_bs);
if (new_bs) {
- QLIST_INSERT_HEAD(&new_bs->parents, child, next_parent);
- if (new_bs->quiesce_counter && child->role->drained_begin) {
- child->role->drained_begin(child);
- }
-
bdrv_get_cumulative_perm(new_bs, &perm, &shared_perm);
if (check_new_perm) {
bdrv_check_perm(new_bs, perm, shared_perm, &error_abort);
}
bdrv_set_perm(new_bs, perm, shared_perm);
-
- if (child->role->attach) {
- child->role->attach(child);
- }
}
}