Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
block: Consistently call bdrv_activate() outside coroutine
Migration code can call bdrv_activate() in coroutine context, whereas
other callers call it outside of coroutines. As it calls other code that
is not supposed to run in coroutines, standardise on running outside of
coroutines.

This adds a no_co_wrapper to switch to the main loop before calling
bdrv_activate().

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20230504115750.54437-3-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit da4afaf)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(mjt: remove [no_]coroutine_fn markers which don't exist in 7.2)
  • Loading branch information
Kevin Wolf authored and Michael Tokarev committed May 11, 2023
1 parent 7406915 commit da9db11
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion block/block-backend.c
Expand Up @@ -1959,7 +1959,15 @@ void blk_activate(BlockBackend *blk, Error **errp)
return;
}

bdrv_activate(bs, errp);
/*
* Migration code can call this function in coroutine context, so leave
* coroutine context if necessary.
*/
if (qemu_in_coroutine()) {
bdrv_co_activate(bs, errp);
} else {
bdrv_activate(bs, errp);
}
}

bool blk_is_inserted(BlockBackend *blk)
Expand Down
3 changes: 3 additions & 0 deletions include/block/block-global-state.h
Expand Up @@ -138,6 +138,9 @@ BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs,
const char *node_name, Error **errp);

int bdrv_activate(BlockDriverState *bs, Error **errp);

int bdrv_co_activate(BlockDriverState *bs, Error **errp);

void bdrv_activate_all(Error **errp);
int bdrv_inactivate_all(void);

Expand Down

0 comments on commit da9db11

Please sign in to comment.