qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, armbru@redhat.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v2 4/5] block/hmp: Allow node-name in 'info block'
Date: Wed, 12 Nov 2014 17:11:17 +0100	[thread overview]
Message-ID: <1415808678-30795-5-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1415808678-30795-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). The new -n options allows listing all named nodes instead of
BlockBackends.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 hmp.c     | 31 ++++++++++++++++++++++++++++++-
 monitor.c |  6 +++---
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/hmp.c b/hmp.c
index 5f8c41d..02d99b1 100644
--- a/hmp.c
+++ b/hmp.c
@@ -403,10 +403,18 @@ 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);
+    bool nodes = qdict_get_try_bool(qdict, "nodes", 0);
+    bool printed = false;
 
-    block_list = qmp_query_block(false);
+    /* Print BlockBackend information */
+    if (!nodes) {
+        block_list = qmp_query_block(false);
+    } else {
+        block_list = NULL;
+    }
 
     for (info = block_list; info; info = info->next) {
         if (device && strcmp(device, info->value->device)) {
@@ -420,9 +428,30 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
         print_block_info(mon, info->value, info->value->has_inserted
                                            ? info->value->inserted : NULL,
                          verbose);
+        printed = true;
     }
 
     qapi_free_BlockInfoList(block_list);
+
+    if ((!device && !nodes) || printed) {
+        return;
+    }
+
+    /* Print node information */
+    blockdev_list = qmp_query_named_block_nodes(NULL);
+    for (blockdev = blockdev_list; blockdev; blockdev = blockdev->next) {
+        assert(blockdev->value->has_node_name);
+        if (device && strcmp(device, blockdev->value->node_name)) {
+            continue;
+        }
+
+        if (blockdev != blockdev_list) {
+            monitor_printf(mon, "\n");
+        }
+
+        print_block_info(mon, NULL, blockdev->value, verbose);
+    }
+    qapi_free_BlockDeviceInfoList(blockdev_list);
 }
 
 void hmp_info_blockstats(Monitor *mon, const QDict *qdict)
diff --git a/monitor.c b/monitor.c
index fa00594..3e7c640 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2628,10 +2628,10 @@ static mon_cmd_t info_cmds[] = {
     },
     {
         .name       = "block",
-        .args_type  = "verbose:-v,device:B?",
-        .params     = "[-v] [device]",
+        .args_type  = "nodes:-n,verbose:-v,device:B?",
+        .params     = "[-n] [-v] [device]",
         .help       = "show info of one block device or all block devices "
-                      "(and details of images with -v option)",
+                      "(-n: show named nodes; -v: show details)",
         .mhandler.cmd = hmp_info_block,
     },
     {
-- 
1.8.3.1

  parent reply	other threads:[~2014-11-12 16:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-12 16:11 [Qemu-devel] [PATCH v2 0/5] block: QMP cache info and HMP node support Kevin Wolf
2014-11-12 16:11 ` [Qemu-devel] [PATCH v2 1/5] block/qapi: Add cache information to query-block Kevin Wolf
2014-11-12 20:37   ` Eric Blake
2014-11-12 16:11 ` [Qemu-devel] [PATCH v2 2/5] block/hmp: Factor out print_block_info() Kevin Wolf
2014-11-12 16:11 ` [Qemu-devel] [PATCH v2 3/5] block/hmp: Allow info = NULL in print_block_info() Kevin Wolf
2014-11-12 16:11 ` Kevin Wolf [this message]
2014-11-12 16:11 ` [Qemu-devel] [PATCH v2 5/5] monitor: Fix HMP tab completion Kevin Wolf
2014-11-21 12:38 ` [Qemu-devel] [PATCH v2 0/5] block: QMP cache info and HMP node support 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=1415808678-30795-5-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@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).