From patchwork Tue Mar 4 07:28:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 326184 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 25A302C00BD for ; Tue, 4 Mar 2014 19:29:49 +1100 (EST) Received: from localhost ([::1]:43545 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKjqM-0000fP-DC for incoming@patchwork.ozlabs.org; Tue, 04 Mar 2014 02:32:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKjoF-0008L5-L4 for qemu-devel@nongnu.org; Tue, 04 Mar 2014 02:30:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WKjoA-0004cq-Oz for qemu-devel@nongnu.org; Tue, 04 Mar 2014 02:30:39 -0500 Received: from [222.73.24.84] (port=33078 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKjoA-0004WB-8n for qemu-devel@nongnu.org; Tue, 04 Mar 2014 02:30:34 -0500 X-IronPort-AV: E=Sophos;i="4.97,583,1389715200"; d="scan'208";a="9641994" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 04 Mar 2014 15:26:26 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s247UFH8004064; Tue, 4 Mar 2014 15:30:18 +0800 Received: from G08FNSTD100614.fnst.cn.fujitsu.com ([10.167.226.102]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2014030415274062-372196 ; Tue, 4 Mar 2014 15:27:40 +0800 From: Hu Tao To: qemu-devel@nongnu.org Date: Tue, 4 Mar 2014 15:28:25 +0800 Message-Id: <94339631aa3871462b1c27df8fc91eb10ab436ee.1393917248.git.hutao@cn.fujitsu.com> X-Mailer: git-send-email 1.8.5.2.229.g4448466 In-Reply-To: References: X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/03/04 15:27:40, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/03/04 15:27:47, Serialize complete at 2014/03/04 15:27:47 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Cc: pbonzini@redhat.com, gaowanlong@cn.fujitsu.com, imammedo@redhat.com Subject: [Qemu-devel] [PATCH v19 11/11] hmp: add info memdev 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 This is the hmp counterpart of qmp query-memdev. Signed-off-by: Hu Tao --- hmp.c | 27 +++++++++++++++++++++++++++ hmp.h | 1 + monitor.c | 7 +++++++ 3 files changed, 35 insertions(+) diff --git a/hmp.c b/hmp.c index e3ddd46..3bbe5ff 100644 --- a/hmp.c +++ b/hmp.c @@ -22,6 +22,8 @@ #include "qemu/sockets.h" #include "monitor/monitor.h" #include "qapi/opts-visitor.h" +#include "qapi/string-output-visitor.h" +#include "qapi-visit.h" #include "ui/console.h" #include "block/qapi.h" #include "qemu-io.h" @@ -1644,3 +1646,28 @@ void hmp_object_del(Monitor *mon, const QDict *qdict) qmp_object_del(id, &err); hmp_handle_error(mon, &err); } + +void hmp_info_memdev(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + MemdevList *memdev_list = qmp_query_memdev(&err); + MemdevList *m = memdev_list; + StringOutputVisitor *ov = string_output_visitor_new(false); + int i = 0; + + + while (m) { + visit_type_uint16List(string_output_get_visitor(ov), + &m->value->host_nodes, NULL, NULL); + monitor_printf(mon, "memory device %d\n", i); + monitor_printf(mon, " size: %ld\n", m->value->size); + monitor_printf(mon, " policy: %s\n", m->value->policy); + monitor_printf(mon, " host nodes: %s\n", string_output_get_string(ov)); + + m = m->next; + i++; + } + + monitor_printf(mon, "\n"); + string_output_visitor_cleanup(ov); +} diff --git a/hmp.h b/hmp.h index ed58f0e..b6f5d02 100644 --- a/hmp.h +++ b/hmp.h @@ -92,5 +92,6 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict); void hmp_cpu_add(Monitor *mon, const QDict *qdict); void hmp_object_add(Monitor *mon, const QDict *qdict); void hmp_object_del(Monitor *mon, const QDict *qdict); +void hmp_info_memdev(Monitor *mon, const QDict *qdict); #endif diff --git a/monitor.c b/monitor.c index d7f1ade..fec4836 100644 --- a/monitor.c +++ b/monitor.c @@ -2949,6 +2949,13 @@ static mon_cmd_t info_cmds[] = { .mhandler.cmd = hmp_info_tpm, }, { + .name = "memdev", + .args_type = "", + .params = "", + .help = "show the memory device", + .mhandler.cmd = hmp_info_memdev, + }, + { .name = NULL, }, };