From: Fabiano Rosas <farosas@suse.de>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, "Kevin Wolf" <kwolf@redhat.com>,
"Hanna Reitz" <hreitz@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"João Silva" <jsilva@suse.de>, "Lin Ma" <lma@suse.com>,
"Claudio Fontana" <cfontana@suse.de>,
"Dario Faggioli" <dfaggioli@suse.com>,
"Eric Blake" <eblake@redhat.com>
Subject: [PATCH v2 07/10] block: Convert qmp_query_named_block_nodes to coroutine
Date: Fri, 9 Jun 2023 17:19:07 -0300 [thread overview]
Message-ID: <20230609201910.12100-8-farosas@suse.de> (raw)
In-Reply-To: <20230609201910.12100-1-farosas@suse.de>
From: Lin Ma <lma@suse.com>
We're converting callers of bdrv_get_allocated_file_size() to run in
coroutines because that function will be made asynchronous when called
(indirectly) from the QMP dispatcher.
This QMP command is a candidate because it indirectly calls
bdrv_get_allocated_file_size() through bdrv_block_device_info() ->
bdrv_query_image_info() -> bdrv_query_image_info().
The previous patches have determined that bdrv_query_image_info() and
bdrv_do_query_node_info() are coroutine-safe so we can just make the
QMP command run in a coroutine.
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
block.c | 2 +-
blockdev.c | 6 +++---
qapi/block-core.json | 3 ++-
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/block.c b/block.c
index f94cee8930..abed744b60 100644
--- a/block.c
+++ b/block.c
@@ -6148,7 +6148,7 @@ BlockDeviceInfoList *bdrv_named_nodes_list(bool flat,
list = NULL;
QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) {
- BlockDeviceInfo *info = bdrv_block_device_info(NULL, bs, flat, errp);
+ BlockDeviceInfo *info = bdrv_co_block_device_info(NULL, bs, flat, errp);
if (!info) {
qapi_free_BlockDeviceInfoList(list);
return NULL;
diff --git a/blockdev.c b/blockdev.c
index e6eba61484..8b5f7d06c8 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2818,9 +2818,9 @@ void qmp_drive_backup(DriveBackup *backup, Error **errp)
blockdev_do_action(&action, errp);
}
-BlockDeviceInfoList *qmp_query_named_block_nodes(bool has_flat,
- bool flat,
- Error **errp)
+BlockDeviceInfoList *coroutine_fn qmp_query_named_block_nodes(bool has_flat,
+ bool flat,
+ Error **errp)
{
bool return_flat = has_flat && flat;
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 5dd5f7e4b0..9d4c92f2c9 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1972,7 +1972,8 @@
{ 'command': 'query-named-block-nodes',
'returns': [ 'BlockDeviceInfo' ],
'data': { '*flat': 'bool' },
- 'allow-preconfig': true }
+ 'allow-preconfig': true,
+ 'coroutine': true}
##
# @XDbgBlockGraphNodeType:
--
2.35.3
next prev parent reply other threads:[~2023-06-09 20:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-09 20:19 [PATCH v2 00/10] block: Make raw_co_get_allocated_file_size asynchronous Fabiano Rosas
2023-06-09 20:19 ` [PATCH v2 01/10] block: Remove bdrv_query_block_node_info Fabiano Rosas
2023-06-09 20:19 ` [PATCH v2 02/10] block: Remove unnecessary variable in bdrv_block_device_info Fabiano Rosas
2023-07-03 14:04 ` Philippe Mathieu-Daudé
2023-06-09 20:19 ` [PATCH v2 03/10] block: Allow the wrapper script to see functions declared in qapi.h Fabiano Rosas
2023-11-06 14:51 ` Hanna Czenczek
2023-06-09 20:19 ` [PATCH v2 04/10] block: Temporarily mark bdrv_co_get_allocated_file_size as mixed Fabiano Rosas
2023-11-06 14:51 ` Hanna Czenczek
2023-06-09 20:19 ` [PATCH v2 05/10] block: Convert bdrv_query_block_graph_info to coroutine Fabiano Rosas
2023-11-06 14:52 ` Hanna Czenczek
2023-06-09 20:19 ` [PATCH v2 06/10] block: Convert bdrv_block_device_info into co_wrapper Fabiano Rosas
2023-11-06 12:51 ` Hanna Czenczek
2023-06-09 20:19 ` Fabiano Rosas [this message]
2023-11-06 12:51 ` [PATCH v2 07/10] block: Convert qmp_query_named_block_nodes to coroutine Hanna Czenczek
2023-06-09 20:19 ` [PATCH v2 08/10] block: Don't query all block devices at hmp_nbd_server_start Fabiano Rosas
2023-11-06 13:07 ` Hanna Czenczek
2023-06-09 20:19 ` [PATCH v2 09/10] block: Convert qmp_query_block() to coroutine_fn Fabiano Rosas
2023-11-06 14:40 ` Hanna Czenczek
2023-11-06 15:02 ` Hanna Czenczek
2023-11-29 20:19 ` Fabiano Rosas
2023-06-09 20:19 ` [PATCH v2 10/10] block: Add a thread-pool version of fstat Fabiano Rosas
2023-11-06 14:52 ` Hanna Czenczek
2023-07-03 13:55 ` [PATCH v2 00/10] block: Make raw_co_get_allocated_file_size asynchronous Fabiano Rosas
2023-08-22 11:52 ` Claudio Fontana
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=20230609201910.12100-8-farosas@suse.de \
--to=farosas@suse.de \
--cc=armbru@redhat.com \
--cc=cfontana@suse.de \
--cc=dfaggioli@suse.com \
--cc=eblake@redhat.com \
--cc=hreitz@redhat.com \
--cc=jsilva@suse.de \
--cc=kwolf@redhat.com \
--cc=lma@suse.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).