/*
* Disassociates the currently associated BlockDriverState from @blk.
+ *
+ * The caller must hold the AioContext lock for the BlockBackend.
*/
void blk_remove_bs(BlockBackend *blk)
{
ThrottleGroupMember *tgm = &blk->public.throttle_group_member;
BdrvChild *root;
+ AioContext *ctx;
GLOBAL_STATE_CODE();
root = blk->root;
blk->root = NULL;
- bdrv_graph_wrlock(NULL);
+ ctx = bdrv_get_aio_context(root->bs);
+ bdrv_graph_wrlock(root->bs);
bdrv_root_unref_child(root);
- bdrv_graph_wrunlock();
+ bdrv_graph_wrunlock_ctx(ctx);
}
/*
int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp)
{
ThrottleGroupMember *tgm = &blk->public.throttle_group_member;
+ AioContext *ctx = bdrv_get_aio_context(bs);
+
GLOBAL_STATE_CODE();
bdrv_ref(bs);
+ bdrv_graph_wrlock(bs);
blk->root = bdrv_root_attach_child(bs, "root", &child_root,
BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
blk->perm, blk->shared_perm,
blk, errp);
+ bdrv_graph_wrunlock_ctx(ctx);
if (blk->root == NULL) {
return -EPERM;
}
int blk_probe_blocksizes(BlockBackend *blk, BlockSizes *bsz)
{
GLOBAL_STATE_CODE();
+ GRAPH_RDLOCK_GUARD_MAINLOOP();
+
if (!blk_is_available(blk)) {
return -ENOMEDIUM;
}
{
BlockBackend *blk = NULL;
GLOBAL_STATE_CODE();
+ GRAPH_RDLOCK_GUARD_MAINLOOP();
while ((blk = blk_all_next(blk)) != NULL) {
AioContext *aio_context = blk_get_aio_context(blk);