diff options
author | Kevin Wolf <kwolf@redhat.com> | 2023-05-04 13:57:32 +0200 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2023-05-10 20:50:38 +0300 |
commit | 38a598aee3c7d716524f1f7c75e9299a879fcc65 (patch) | |
tree | 8feb59c523afc2af17a66dbc41f608238a02b502 /block | |
parent | 2197a94cb461c3bfff9d183ae79d4c99964163c4 (diff) |
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 da4afaff074e56b0fa0d25abf865784148018895)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'block')
-rw-r--r-- | block/block-backend.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/block/block-backend.c b/block/block-backend.c index 55efc735b4..d59f759daf 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2018,7 +2018,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 coroutine_fn blk_co_is_inserted(BlockBackend *blk) |