From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkRpF-0004So-Jd for qemu-devel@nongnu.org; Thu, 06 Jun 2013 00:29:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkRpE-0001Fb-Ku for qemu-devel@nongnu.org; Thu, 06 Jun 2013 00:29:25 -0400 Received: from e23smtp05.au.ibm.com ([202.81.31.147]:38204) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkRpE-0001FK-27 for qemu-devel@nongnu.org; Thu, 06 Jun 2013 00:29:24 -0400 Received: from /spool/local by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Jun 2013 14:23:35 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 5F9812CE8023 for ; Thu, 6 Jun 2013 14:29:19 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r564EiNq1966394 for ; Thu, 6 Jun 2013 14:14:44 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r564TIdS015784 for ; Thu, 6 Jun 2013 14:29:18 +1000 From: Wenchao Xia Date: Thu, 6 Jun 2013 12:28:01 +0800 Message-Id: <1370492881-12410-6-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1370492881-12410-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1370492881-12410-1-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH V15 5/5] 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, armbru@redhat.com, lcapitulino@redhat.com, stefanha@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 --- hmp.c | 25 ++++++++++++++++--------- monitor.c | 7 ++++--- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/hmp.c b/hmp.c index 2aa832c..9e11e07 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"); + bool 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,15 +326,17 @@ 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((fprintf_function)monitor_printf, mon, - 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((fprintf_function)monitor_printf, + mon, 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 eefc7f0..80ad531 100644 --- a/monitor.c +++ b/monitor.c @@ -2472,9 +2472,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