From patchwork Tue Apr 2 11:47:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 232981 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 749C82C0095 for ; Tue, 2 Apr 2013 22:56:19 +1100 (EST) Received: from localhost ([::1]:36773 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMzp2-0003Lo-Or for incoming@patchwork.ozlabs.org; Tue, 02 Apr 2013 07:56:16 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49534) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMzjb-0003jk-1V for qemu-devel@nongnu.org; Tue, 02 Apr 2013 07:50:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UMzjY-000445-3j for qemu-devel@nongnu.org; Tue, 02 Apr 2013 07:50:38 -0400 Received: from e28smtp08.in.ibm.com ([122.248.162.8]:56770) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMzjX-00042i-9F for qemu-devel@nongnu.org; Tue, 02 Apr 2013 07:50:35 -0400 Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 2 Apr 2013 17:15:24 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp08.in.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 2 Apr 2013 17:15:20 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 48F03E004A for ; Tue, 2 Apr 2013 17:22:09 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r32BoOP72032038 for ; Tue, 2 Apr 2013 17:20:24 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r32BoPWE005058 for ; Tue, 2 Apr 2013 11:50:27 GMT Received: from RH63Wenchao (wenchaox.cn.ibm.com [9.115.122.29]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r32BlY3I025943; Tue, 2 Apr 2013 11:50:23 GMT From: Wenchao Xia To: qemu-devel@nongnu.org Date: Tue, 2 Apr 2013 19:47:30 +0800 Message-Id: <1364903250-10429-18-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1364903250-10429-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1364903250-10429-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13040211-2000-0000-0000-00000B9466BE X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.8 Cc: kwolf@redhat.com, stefanha@gmail.com, armbru@redhat.com, lcapitulino@redhat.com, pbonzini@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V11 17/17] hmp: add parameters device and -v for info block X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org With these parameters, user can choose the information to be showed, to avoid message flood in the montior. Signed-off-by: Wenchao Xia --- 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, }, {