[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V11 17/17] hmp: add parameters device and -v for inf
From: |
Wenchao Xia |
Subject: |
[Qemu-devel] [PATCH V11 17/17] hmp: add parameters device and -v for info block |
Date: |
Tue, 2 Apr 2013 19:47:30 +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 | 34 ++++++++++++++++++++--------------
monitor.c | 7 ++++---
2 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/hmp.c b/hmp.c
index 6f93fcd..677bc7f 100644
--- a/hmp.c
+++ b/hmp.c
@@ -280,10 +280,15 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
BlockInfoList *block_list, *info;
ImageInfo *image_info;
GString *buf = NULL;
+ const char *device = qdict_get_try_str(qdict, "device");
+ int verbose = qdict_get_try_bool(qdict, "verbose", 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);
@@ -322,22 +327,23 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
info->value->inserted->iops_rd,
info->value->inserted->iops_wr);
- if (!buf) {
- buf = g_string_sized_new(2048);
- }
- monitor_printf(mon, " images:\n");
- image_info = info->value->inserted->image;
- while (1) {
- bdrv_image_info_dump(buf, image_info);
- monitor_printf(mon, "%s", buf->str);
- g_string_set_size(buf, 0);
- if (image_info->has_backing_image) {
- image_info = image_info->backing_image;
- } else {
- break;
+ if (verbose) {
+ if (!buf) {
+ buf = g_string_sized_new(2048);
+ }
+ monitor_printf(mon, " images:\n");
+ image_info = info->value->inserted->image;
+ while (1) {
+ bdrv_image_info_dump(buf, image_info);
+ monitor_printf(mon, "%s", buf->str);
+ g_string_set_size(buf, 0);
+ if (image_info->has_backing_image) {
+ image_info = image_info->backing_image;
+ } else {
+ break;
+ }
}
}
-
} else {
monitor_printf(mon, " [not inserted]");
}
diff --git a/monitor.c b/monitor.c
index 4720207..ae5a61e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2465,9 +2465,10 @@ static mon_cmd_t info_cmds[] = {
},
{
.name = "block",
- .args_type = "",
- .params = "",
- .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 details of images with -v option)",
.mhandler.cmd = hmp_info_block,
},
{
--
1.7.1
- [Qemu-devel] [PATCH V11 13/17] block: dump to buffer for bdrv_snapshot_dump() and bdrv_image_info_dump(), (continued)
[Qemu-devel] [PATCH V11 16/17] hmp: show ImageInfo in 'info block', Wenchao Xia, 2013/04/02
[Qemu-devel] [PATCH V11 15/17] hmp: switch snapshot info function to qmp based one, Wenchao Xia, 2013/04/02
[Qemu-devel] [PATCH V11 17/17] hmp: add parameters device and -v for info block,
Wenchao Xia <=
[Qemu-devel] [PATCH V11 14/17] hmp: add function hmp_info_snapshots(), Wenchao Xia, 2013/04/02
Re: [Qemu-devel] [PATCH V11 00/17] qmp/hmp interfaces for internal snapshot info, Wenchao Xia, 2013/04/07
Re: [Qemu-devel] [PATCH V11 00/17] qmp/hmp interfaces for internal snapshot info, Kevin Wolf, 2013/04/08
Re: [Qemu-devel] [PATCH V11 00/17] qmp/hmp interfaces for internal snapshot info, Stefan Hajnoczi, 2013/04/08
Re: [Qemu-devel] [PATCH V11 00/17] qmp/hmp interfaces for internal snapshot info, Markus Armbruster, 2013/04/11