diff mbox

[V10,17/17] hmp: add parameter device and -b for info block

Message ID 1363961953-13561-18-git-send-email-xiawenc@linux.vnet.ibm.com
State New
Headers show

Commit Message

Wayne Xia March 22, 2013, 2:19 p.m. UTC
With these parameters, user can choose the information to be showed,
to avoid message flood in the montior.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 hmp.c     |    7 ++++++-
 monitor.c |    7 ++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

Comments

Kevin Wolf March 28, 2013, 11:09 a.m. UTC | #1
Am 22.03.2013 um 15:19 hat Wenchao Xia geschrieben:
>   With these parameters, user can choose the information to be showed,
> to avoid message flood in the montior.
> 
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>

Aha, so here you actually introduce the 'device' parameter. If you can
have this patch first, and only then patch 16, then limiting the new
output to the form with a device specified should be trivial.

> --- 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",

That '[' doesn't look intentional?

Kevin
Wayne Xia March 29, 2013, 2:48 a.m. UTC | #2
于 2013-3-28 19:09, Kevin Wolf 写道:
> Am 22.03.2013 um 15:19 hat Wenchao Xia geschrieben:
>>    With these parameters, user can choose the information to be showed,
>> to avoid message flood in the montior.
>>
>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>
> Aha, so here you actually introduce the 'device' parameter. If you can
> have this patch first, and only then patch 16, then limiting the new
> output to the form with a device specified should be trivial.
>
   It is a bit indirect that "info block" and "info block <device>"
show different on single device, so I introduced additional parameter
'-b' to filter out info. With more thinking, I think it should be
{
         .name       = "block",
         .help       = "show the block devices",
         .args_type  = "verbose:-v,device:B?",
         .params     = "[-v] [device]",
         .help       = "show info of one block device or all block devices "
                       "and detail of images with -v option",
}
   Then by default "info block" so brief summary as old time. Since the
"-v" parameter is filtering something out not present on patch 15,
so I can't move this patch forward, hope you are OK with it.

>> --- 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",
>
> That '[' doesn't look intentional?
   my hand shaking... will correct it.

>
> Kevin
>
Kevin Wolf April 2, 2013, 7:46 a.m. UTC | #3
Am 29.03.2013 um 03:48 hat Wenchao Xia geschrieben:
> 于 2013-3-28 19:09, Kevin Wolf 写道:
> >Am 22.03.2013 um 15:19 hat Wenchao Xia geschrieben:
> >>   With these parameters, user can choose the information to be showed,
> >>to avoid message flood in the montior.
> >>
> >>Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> >
> >Aha, so here you actually introduce the 'device' parameter. If you can
> >have this patch first, and only then patch 16, then limiting the new
> >output to the form with a device specified should be trivial.
> >
>   It is a bit indirect that "info block" and "info block <device>"
> show different on single device, so I introduced additional parameter
> '-b' to filter out info. With more thinking, I think it should be
> {
>         .name       = "block",
>         .help       = "show the block devices",
>         .args_type  = "verbose:-v,device:B?",
>         .params     = "[-v] [device]",
>         .help       = "show info of one block device or all block devices "
>                       "and detail of images with -v option",
> }
>   Then by default "info block" so brief summary as old time. Since the
> "-v" parameter is filtering something out not present on patch 15,
> so I can't move this patch forward, hope you are OK with it.

'info block [-v] [<device>]' is okay with me. I would prefer if you
could arrange the patches so that without -v you never get verbose
output in any intermediate patch, but otherwise I don't mind about
the order of patches.

Kevin
diff mbox

Patch

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,
     },
     {