aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2019-04-24 17:41:46 +0200
committerKevin Wolf <kwolf@redhat.com>2019-06-04 15:22:22 +0200
commit132ada80c4a6fea7b67e8bb0a5fd299994d927c6 (patch)
tree3457b1a3fb7bc3c40ec2d1bbed86b374809ce79f /block
parent4f71fb436a6fbec7a7b2360cdba741deeb24be67 (diff)
downloadqemu-132ada80c4a6fea7b67e8bb0a5fd299994d927c6.zip
qemu-132ada80c4a6fea7b67e8bb0a5fd299994d927c6.tar.gz
qemu-132ada80c4a6fea7b67e8bb0a5fd299994d927c6.tar.bz2
block: Adjust AioContexts when attaching nodes
So far, we only made sure that updating the AioContext of a node affected the whole subtree. However, if a node is newly attached to a new parent, we also need to make sure that both the subtree of the node and the parent are in the same AioContext. This tries to move the new child node to the parent AioContext and returns an error if this isn't possible. BlockBackends now actually apply their AioContext to their root node. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/block-backend.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/block/block-backend.c b/block/block-backend.c
index f03f14a..f5d9407 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -392,7 +392,7 @@ BlockBackend *blk_new_open(const char *filename, const char *reference,
return NULL;
}
- blk->root = bdrv_root_attach_child(bs, "root", &child_root,
+ blk->root = bdrv_root_attach_child(bs, "root", &child_root, blk->ctx,
perm, BLK_PERM_ALL, blk, errp);
if (!blk->root) {
blk_unref(blk);
@@ -803,7 +803,7 @@ int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp)
{
ThrottleGroupMember *tgm = &blk->public.throttle_group_member;
bdrv_ref(bs);
- blk->root = bdrv_root_attach_child(bs, "root", &child_root,
+ blk->root = bdrv_root_attach_child(bs, "root", &child_root, blk->ctx,
blk->perm, blk->shared_perm, blk, errp);
if (blk->root == NULL) {
return -EPERM;
@@ -1861,10 +1861,9 @@ AioContext *blk_get_aio_context(BlockBackend *blk)
{
BlockDriverState *bs = blk_bs(blk);
- /* FIXME The AioContext of bs and blk can be inconsistent. For the moment,
- * we prefer the one of bs for compatibility. */
if (bs) {
- return bdrv_get_aio_context(blk_bs(blk));
+ AioContext *ctx = bdrv_get_aio_context(blk_bs(blk));
+ assert(ctx == blk->ctx);
}
return blk->ctx;