From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 3/6] block: Introduce query-block-node
Date: Tue, 16 Sep 2014 17:36:33 +0200 [thread overview]
Message-ID: <1410881796-18452-4-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1410881796-18452-1-git-send-email-kwolf@redhat.com>
This new command is a renamed version of query-named-block-nodes
with an additional argument that allows querying only one specific
BlockDriverState instead of getting a list for all of them.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 15 +++++++++++++--
blockdev.c | 8 +++++++-
include/block/block.h | 2 +-
qapi/block-core.json | 19 ++++++++++++++++---
4 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/block.c b/block.c
index bcd952a..6c538d3 100644
--- a/block.c
+++ b/block.c
@@ -3823,13 +3823,24 @@ BlockDriverState *bdrv_find_node(const char *node_name)
}
/* Put this QMP function here so it can access the static graph_bdrv_states. */
-BlockDeviceInfoList *bdrv_named_nodes_list(void)
+BlockDeviceInfoList *bdrv_named_nodes_list(const char *device, Error **errp)
{
BlockDeviceInfoList *list, *entry;
BlockDriverState *bs;
+ Error *local_err = NULL;
+
+ if (device) {
+ bs = bdrv_lookup_bs(device, device, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return NULL;
+ }
+ } else {
+ bs = QTAILQ_FIRST(&graph_bdrv_states);
+ }
list = NULL;
- QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) {
+ for (; bs; bs = device ? NULL : QTAILQ_NEXT(bs, node_list)) {
entry = g_malloc0(sizeof(*entry));
entry->value = bdrv_block_device_info(bs);
entry->next = list;
diff --git a/blockdev.c b/blockdev.c
index b361fbb..a194d04 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2127,9 +2127,15 @@ void qmp_drive_backup(const char *device, const char *target,
}
}
+BlockDeviceInfoList *qmp_query_block_node(bool has_device, const char *device,
+ Error **errp)
+{
+ return bdrv_named_nodes_list(has_device ? device : NULL, errp);
+}
+
BlockDeviceInfoList *qmp_query_named_block_nodes(Error **errp)
{
- return bdrv_named_nodes_list();
+ return qmp_query_block_node(false, NULL, errp);
}
#define DEFAULT_MIRROR_BUF_SIZE (10 << 20)
diff --git a/include/block/block.h b/include/block/block.h
index 07d6d8e..0caab0d 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -403,7 +403,7 @@ void bdrv_eject(BlockDriverState *bs, bool eject_flag);
const char *bdrv_get_format_name(BlockDriverState *bs);
BlockDriverState *bdrv_find(const char *name);
BlockDriverState *bdrv_find_node(const char *node_name);
-BlockDeviceInfoList *bdrv_named_nodes_list(void);
+BlockDeviceInfoList *bdrv_named_nodes_list(const char *device, Error **errp);
BlockDriverState *bdrv_lookup_bs(const char *device,
const char *node_name,
Error **errp);
diff --git a/qapi/block-core.json b/qapi/block-core.json
index ddc3fe0..f170c7e 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -797,13 +797,26 @@
##
# @query-named-block-nodes
#
-# Get the named block driver list
+# Deprecated, may be removed in future versions. Use query-block-node instead.
+#
+# Since 2.0, until 2.1
+##
+{ 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] }
+
+##
+# @query-block-node
+#
+# Gets information about one or all block device nodes.
+#
+# @device: #optional The id or node-name of the block device to inspect.
#
# Returns: the list of BlockDeviceInfo
#
-# Since 2.0
+# Since 2.2
##
-{ 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] }
+{ 'command': 'query-block-node',
+ 'data': { '*device': 'str' },
+ 'returns': [ 'BlockDeviceInfo' ] }
##
# @drive-mirror
--
1.8.3.1
next prev parent reply other threads:[~2014-09-16 15:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-16 15:36 [Qemu-devel] [PATCH 0/6] block: Single-device query-block(-node) and cache info Kevin Wolf
2014-09-16 15:36 ` [Qemu-devel] [PATCH 1/6] block/qapi: Add cache information to query-block Kevin Wolf
2014-09-18 11:04 ` Markus Armbruster
2014-09-18 11:38 ` Markus Armbruster
2014-09-18 11:53 ` Kevin Wolf
2014-09-18 12:46 ` Markus Armbruster
2014-09-18 12:49 ` Eric Blake
2014-09-16 15:36 ` [Qemu-devel] [PATCH 2/6] block: Add optional device argument " Kevin Wolf
2014-09-18 11:53 ` Markus Armbruster
2014-09-16 15:36 ` Kevin Wolf [this message]
2014-09-18 11:59 ` [Qemu-devel] [PATCH 3/6] block: Introduce query-block-node Markus Armbruster
2014-09-16 15:36 ` [Qemu-devel] [PATCH 4/6] block/hmp: Factor out print_block_info() Kevin Wolf
2014-09-16 15:36 ` [Qemu-devel] [PATCH 5/6] block/hmp: Allow info = NULL in print_block_info() Kevin Wolf
2014-09-16 15:36 ` [Qemu-devel] [PATCH 6/6] block: Allow node-name in HMP 'info block' Kevin Wolf
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=1410881796-18452-4-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--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).