From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQwL1-0002eq-Ay for qemu-devel@nongnu.org; Sat, 13 Apr 2013 05:01:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQwL0-0001Cx-Ct for qemu-devel@nongnu.org; Sat, 13 Apr 2013 05:01:35 -0400 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:32967) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQwKz-0001Ch-Sq for qemu-devel@nongnu.org; Sat, 13 Apr 2013 05:01:34 -0400 Received: from /spool/local by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 13 Apr 2013 18:50:08 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 3BE56357804E for ; Sat, 13 Apr 2013 19:01:30 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3D90sDV6750560 for ; Sat, 13 Apr 2013 19:00:54 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3D90xQ0030491 for ; Sat, 13 Apr 2013 19:00:59 +1000 From: Wenchao Xia Date: Sat, 13 Apr 2013 16:56:47 +0800 Message-Id: <1365843407-16504-19-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1365843407-16504-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1365843407-16504-1-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH V12 18/18] hmp: add parameters device and -v for info block List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, phrdina@redhat.com, stefanha@gmail.com, armbru@redhat.com, lcapitulino@redhat.com, pbonzini@redhat.com, Wenchao Xia With these parameters, user can choose the information to be showed, to avoid message flood in the monitor. Signed-off-by: Wenchao Xia Reviewed-by: Kevin Wolf --- hmp.c | 23 +++++++++++++++-------- monitor.c | 7 ++++--- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/hmp.c b/hmp.c index 1d13030..4780873 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; + 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); @@ -321,14 +326,16 @@ void hmp_info_block(Monitor *mon, const QDict *qdict) info->value->inserted->iops_rd, info->value->inserted->iops_wr); - monitor_printf(mon, " images:\n"); - image_info = info->value->inserted->image; - while (1) { - bdrv_image_info_dump(image_info); - if (image_info->has_backing_image) { - image_info = image_info->backing_image; - } else { - break; + if (verbose) { + monitor_printf(mon, " images:\n"); + image_info = info->value->inserted->image; + while (1) { + bdrv_image_info_dump(image_info); + if (image_info->has_backing_image) { + image_info = image_info->backing_image; + } else { + break; + } } } } else { diff --git a/monitor.c b/monitor.c index a2b1e3f..91a7066 100644 --- a/monitor.c +++ b/monitor.c @@ -2474,9 +2474,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