hmp: add parameters device and -v for info block

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

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Wenchao Xia 2013-06-06 12:28:01 +08:00 committed by Stefan Hajnoczi
parent bd093a365e
commit e73fe2b46c
2 changed files with 20 additions and 12 deletions

25
hmp.c
View File

@ -280,10 +280,15 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
{ {
BlockInfoList *block_list, *info; BlockInfoList *block_list, *info;
ImageInfo *image_info; ImageInfo *image_info;
const char *device = qdict_get_try_str(qdict, "device");
bool verbose = qdict_get_try_bool(qdict, "verbose", 0);
block_list = qmp_query_block(NULL); block_list = qmp_query_block(NULL);
for (info = block_list; info; info = info->next) { for (info = block_list; info; info = info->next) {
if (device && strcmp(device, info->value->device)) {
continue;
}
monitor_printf(mon, "%s: removable=%d", monitor_printf(mon, "%s: removable=%d",
info->value->device, info->value->removable); info->value->device, info->value->removable);
@ -322,15 +327,17 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
info->value->inserted->iops_rd, info->value->inserted->iops_rd,
info->value->inserted->iops_wr); info->value->inserted->iops_wr);
monitor_printf(mon, " images:\n"); if (verbose) {
image_info = info->value->inserted->image; monitor_printf(mon, " images:\n");
while (1) { image_info = info->value->inserted->image;
bdrv_image_info_dump((fprintf_function)monitor_printf, mon, while (1) {
image_info); bdrv_image_info_dump((fprintf_function)monitor_printf,
if (image_info->has_backing_image) { mon, image_info);
image_info = image_info->backing_image; if (image_info->has_backing_image) {
} else { image_info = image_info->backing_image;
break; } else {
break;
}
} }
} }
} else { } else {

View File

@ -2472,9 +2472,10 @@ static mon_cmd_t info_cmds[] = {
}, },
{ {
.name = "block", .name = "block",
.args_type = "", .args_type = "verbose:-v,device:B?",
.params = "", .params = "[-v] [device]",
.help = "show the block devices", .help = "show info of one block device or all block devices "
"(and details of images with -v option)",
.mhandler.cmd = hmp_info_block, .mhandler.cmd = hmp_info_block,
}, },
{ {