From patchwork Fri Mar 22 14:19:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 230095 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 74C0C2C00C0 for ; Sat, 23 Mar 2013 02:28:20 +1100 (EST) Received: from localhost ([::1]:41681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ33c-0000Kz-LH for incoming@patchwork.ozlabs.org; Fri, 22 Mar 2013 10:35:00 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ2sR-0002yZ-92 for qemu-devel@nongnu.org; Fri, 22 Mar 2013 10:23:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UJ2sL-0006xa-OJ for qemu-devel@nongnu.org; Fri, 22 Mar 2013 10:23:27 -0400 Received: from e28smtp07.in.ibm.com ([122.248.162.7]:39321) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ2sL-0006ww-5c for qemu-devel@nongnu.org; Fri, 22 Mar 2013 10:23:21 -0400 Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 22 Mar 2013 19:49:29 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 22 Mar 2013 19:49:27 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 3495EE0056 for ; Fri, 22 Mar 2013 19:54:47 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2MENEBg9503136 for ; Fri, 22 Mar 2013 19:53:14 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2MENFTx029239 for ; Sat, 23 Mar 2013 01:23:16 +1100 Received: from RH63Wenchao ([9.125.29.101]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r2MEJPjt008189; Sat, 23 Mar 2013 01:23:12 +1100 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Fri, 22 Mar 2013 22:19:13 +0800 Message-Id: <1363961953-13561-18-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1363961953-13561-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1363961953-13561-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13032214-8878-0000-0000-0000066834DC X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.7 Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanha@gmail.com, armbru@redhat.com, lcapitulino@redhat.com, pbonzini@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V10 17/17] hmp: add parameter device and -b 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 | 7 ++++++- monitor.c | 7 ++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hmp.c b/hmp.c index 49f851b..3a2ba54 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; char *buf = NULL; + const char *device = qdict_get_try_str(qdict, "device"); + int backing = qdict_get_try_bool(qdict, "backing", 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); @@ -329,7 +334,7 @@ void hmp_info_block(Monitor *mon, const QDict *qdict) while (1) { bdrv_image_info_dump(buf, IMAGE_INFO_BUF_SIZE, image_info); monitor_printf(mon, "%s", buf); - if (image_info->has_backing_image) { + if (backing && image_info->has_backing_image) { image_info = image_info->backing_image; } else { break; diff --git a/monitor.c b/monitor.c index e927c71..055252e 100644 --- a/monitor.c +++ b/monitor.c @@ -2455,9 +2455,10 @@ static mon_cmd_t info_cmds[] = { }, { .name = "block", - .args_type = "", - .params = "", - .help = "show the block devices", + .args_type = "backing:-b,device:B?", + .params = "[-b] [device]", + .help = "show info of one block device or all block devices " + "[and info of backing images with -b option", .mhandler.cmd = hmp_info_block, }, {