From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 6/6] block: Allow node-name in HMP 'info block'
Date: Tue, 16 Sep 2014 17:36:36 +0200 [thread overview]
Message-ID: <1410881796-18452-7-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1410881796-18452-1-git-send-email-kwolf@redhat.com>
The optional parameter specifying a block device allows now to use a
node-name instead of a drive name (and therefore to inspect any node in
the graph).
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
hmp.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/hmp.c b/hmp.c
index 811ceba..945e5fa 100644
--- a/hmp.c
+++ b/hmp.c
@@ -403,26 +403,34 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
void hmp_info_block(Monitor *mon, const QDict *qdict)
{
BlockInfoList *block_list, *info;
+ BlockDeviceInfoList *blockdev_list, *blockdev;
const char *device = qdict_get_try_str(qdict, "device");
bool verbose = qdict_get_try_bool(qdict, "verbose", 0);
- block_list = qmp_query_block(false, NULL, NULL);
+ block_list = qmp_query_block(!!device, device, NULL);
+ if (block_list) {
+ for (info = block_list; info; info = info->next) {
+ if (info != block_list) {
+ monitor_printf(mon, "\n");
+ }
- for (info = block_list; info; info = info->next) {
- if (device && strcmp(device, info->value->device)) {
- continue;
+ print_block_info(mon, info->value, info->value->has_inserted
+ ? info->value->inserted : NULL,
+ verbose);
}
+ qapi_free_BlockInfoList(block_list);
+ return;
+ }
- if (info != block_list) {
+ blockdev_list = qmp_query_block_node(!!device, device, NULL);
+ for (blockdev = blockdev_list; blockdev; blockdev = blockdev->next) {
+ if (blockdev != blockdev_list) {
monitor_printf(mon, "\n");
}
- print_block_info(mon, info->value, info->value->has_inserted
- ? info->value->inserted : NULL,
- verbose);
+ print_block_info(mon, NULL, blockdev->value, verbose);
}
-
- qapi_free_BlockInfoList(block_list);
+ qapi_free_BlockDeviceInfoList(blockdev_list);
}
void hmp_info_blockstats(Monitor *mon, const QDict *qdict)
--
1.8.3.1
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 ` [Qemu-devel] [PATCH 3/6] block: Introduce query-block-node Kevin Wolf
2014-09-18 11:59 ` 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 ` Kevin Wolf [this message]
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-7-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).