From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com, eblake@redhat.com,
eesposit@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org
Subject: [PATCH v2 02/20] block: Consistently call bdrv_activate() outside coroutine
Date: Thu, 4 May 2023 13:57:32 +0200 [thread overview]
Message-ID: <20230504115750.54437-3-kwolf@redhat.com> (raw)
In-Reply-To: <20230504115750.54437-1-kwolf@redhat.com>
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().
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
include/block/block-global-state.h | 6 +++++-
block/block-backend.c | 10 +++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/include/block/block-global-state.h b/include/block/block-global-state.h
index 399200a9a3..2c312cc774 100644
--- a/include/block/block-global-state.h
+++ b/include/block/block-global-state.h
@@ -166,7 +166,11 @@ int bdrv_amend_options(BlockDriverState *bs_new, QemuOpts *opts,
BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs,
const char *node_name, Error **errp);
-int bdrv_activate(BlockDriverState *bs, Error **errp);
+int no_coroutine_fn bdrv_activate(BlockDriverState *bs, Error **errp);
+
+int coroutine_fn no_co_wrapper
+bdrv_co_activate(BlockDriverState *bs, Error **errp);
+
void bdrv_activate_all(Error **errp);
int bdrv_inactivate_all(void);
diff --git a/block/block-backend.c b/block/block-backend.c
index fc530ded6a..e37d55d3e9 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -2024,7 +2024,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)
--
2.40.1
next prev parent reply other threads:[~2023-05-04 11:58 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-04 11:57 [PATCH v2 00/20] Graph locking, part 3 (more block drivers) Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 01/20] qcow2: Don't call bdrv_getlength() in coroutine_fns Kevin Wolf
2023-05-04 11:57 ` Kevin Wolf [this message]
2023-05-04 11:57 ` [PATCH v2 03/20] block: bdrv/blk_co_unref() for calls in coroutine context Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 04/20] block: Don't call no_coroutine_fns in qmp_block_resize() Kevin Wolf
2023-05-05 12:02 ` Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 05/20] test-bdrv-drain: Don't modify the graph in coroutines Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 06/20] graph-lock: Add GRAPH_UNLOCKED(_PTR) Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 07/20] graph-lock: Fix GRAPH_RDLOCK_GUARD*() to be reader lock Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 08/20] block: .bdrv_open is non-coroutine and unlocked Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 09/20] nbd: Remove nbd_co_flush() wrapper function Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 10/20] nbd: Mark nbd_co_do_establish_connection() and callers GRAPH_RDLOCK Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 11/20] vhdx: Require GRAPH_RDLOCK for accessing a node's parent list Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 12/20] mirror: " Kevin Wolf
2023-05-04 13:17 ` Eric Blake
2023-05-04 15:17 ` Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 13/20] block: Mark bdrv_co_get_allocated_file_size() and callers GRAPH_RDLOCK Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 14/20] block: Mark bdrv_co_get_info() " Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 15/20] block: Mark bdrv_co_debug_event() GRAPH_RDLOCK Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 16/20] block: Mark BlockDriver callbacks for amend job GRAPH_RDLOCK Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 17/20] block: Mark bdrv_query_bds_stats() and callers GRAPH_RDLOCK Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 18/20] block: Mark bdrv_query_block_graph_info() " Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 19/20] block: Mark bdrv_recurse_can_replace() " Kevin Wolf
2023-05-04 11:57 ` [PATCH v2 20/20] block: Mark bdrv_refresh_limits() " Kevin Wolf
2023-05-09 17:07 ` [PATCH v2 00/20] Graph locking, part 3 (more block drivers) Kevin Wolf
2023-05-09 17:48 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230504115750.54437-3-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=eblake@redhat.com \
--cc=eesposit@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).