summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorKevin Wolf2016-05-17 14:51:55 +0200
committerKevin Wolf2016-05-25 19:04:10 +0200
commit36fe13317bfc3414745528c6c08cea2904ca49ec (patch)
tree5c0d2dab6123311014f8b5e3bae6e9528859e21b /block
parentblock: Make bdrv_drain() use bdrv_drained_begin/end() (diff)
downloadqemu-36fe13317bfc3414745528c6c08cea2904ca49ec.tar.gz
qemu-36fe13317bfc3414745528c6c08cea2904ca49ec.tar.xz
qemu-36fe13317bfc3414745528c6c08cea2904ca49ec.zip
block: Fix reconfiguring graph with drained nodes
When changing the BlockDriverState that a BdrvChild points to while the node is currently drained, we must call the .drained_end() parent callback. Conversely, when this means attaching a new node that is already drained, we need to call .drained_begin(). bdrv_root_attach_child() takes now an opaque parameter, which is needed because the callbacks must also be called if we're attaching a new child to the BlockBackend when the root node is already drained, and they need a way to identify the BlockBackend. Previously, child->opaque was set too late and the callbacks would still see it as NULL. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/block-backend.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/block/block-backend.c b/block/block-backend.c
index 4e8298b291..14e528ea82 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -161,8 +161,7 @@ BlockBackend *blk_new_open(const char *filename, const char *reference,
}
blk_set_enable_write_cache(blk, true);
- blk->root = bdrv_root_attach_child(bs, "root", &child_root);
- blk->root->opaque = blk;
+ blk->root = bdrv_root_attach_child(bs, "root", &child_root, blk);
return blk;
}
@@ -481,8 +480,7 @@ void blk_remove_bs(BlockBackend *blk)
void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs)
{
bdrv_ref(bs);
- blk->root = bdrv_root_attach_child(bs, "root", &child_root);
- blk->root->opaque = blk;
+ blk->root = bdrv_root_attach_child(bs, "root", &child_root, blk);
notifier_list_notify(&blk->insert_bs_notifiers, blk);
if (blk->public.throttle_state) {
@@ -1676,6 +1674,9 @@ static void blk_root_drained_begin(BdrvChild *child)
{
BlockBackend *blk = child->opaque;
+ /* Note that blk->root may not be accessible here yet if we are just
+ * attaching to a BlockDriverState that is drained. Use child instead. */
+
if (blk->public.io_limits_disabled++ == 0) {
throttle_group_restart_blk(blk);
}