qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH V10 17/17] hmp: add parameter device and -b for info


From: Wenchao Xia
Subject: [Qemu-devel] [PATCH V10 17/17] hmp: add parameter device and -b for info block
Date: Fri, 22 Mar 2013 22:19:13 +0800

  With these parameters, user can choose the information to be showed,
to avoid message flood in the montior.

Signed-off-by: Wenchao Xia <address@hidden>
---
 hmp.c     |    7 ++++++-
 monitor.c |    7 ++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/hmp.c b/hmp.c
index 49f851b..3a2ba54 100644
--- a/hmp.c
+++ b/hmp.c
@@ -279,10 +279,15 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
     BlockInfoList *block_list, *info;
     ImageInfo *image_info;
     char *buf = NULL;
+    const char *device = qdict_get_try_str(qdict, "device");
+    int backing = qdict_get_try_bool(qdict, "backing", 0);
 
     block_list = qmp_query_block(NULL);
 
     for (info = block_list; info; info = info->next) {
+        if (device && strcmp(device, info->value->device)) {
+            continue;
+        }
         monitor_printf(mon, "%s: removable=%d",
                        info->value->device, info->value->removable);
 
@@ -329,7 +334,7 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
             while (1) {
                 bdrv_image_info_dump(buf, IMAGE_INFO_BUF_SIZE, image_info);
                 monitor_printf(mon, "%s", buf);
-                if (image_info->has_backing_image) {
+                if (backing && image_info->has_backing_image) {
                     image_info = image_info->backing_image;
                 } else {
                     break;
diff --git a/monitor.c b/monitor.c
index e927c71..055252e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2455,9 +2455,10 @@ static mon_cmd_t info_cmds[] = {
     },
     {
         .name       = "block",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show the block devices",
+        .args_type  = "backing:-b,device:B?",
+        .params     = "[-b] [device]",
+        .help       = "show info of one block device or all block devices "
+                      "[and info of backing images with -b option",
         .mhandler.cmd = hmp_info_block,
     },
     {
-- 
1.7.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]