From patchwork Wed May 14 09:43:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 348707 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 62C66140080 for ; Wed, 14 May 2014 19:52:40 +1000 (EST) Received: from localhost ([::1]:50543 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkVrS-00019w-On for incoming@patchwork.ozlabs.org; Wed, 14 May 2014 05:52:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkVlH-00065g-8h for qemu-devel@nongnu.org; Wed, 14 May 2014 05:46:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkVl9-0006OY-OW for qemu-devel@nongnu.org; Wed, 14 May 2014 05:46:07 -0400 Received: from [59.151.112.132] (port=49428 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkVl9-0006Hh-Bd for qemu-devel@nongnu.org; Wed, 14 May 2014 05:45:59 -0400 X-IronPort-AV: E=Sophos;i="4.97,1051,1389715200"; d="scan'208";a="30507104" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 14 May 2014 17:43:21 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s4E9jqSh002843; Wed, 14 May 2014 17:45:53 +0800 Received: from G08FNSTD100614.fnst.cn.fujitsu.com (10.167.226.102) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.146.2; Wed, 14 May 2014 17:46:03 +0800 From: Hu Tao To: Date: Wed, 14 May 2014 17:43:35 +0800 Message-ID: <5f64b90d8707869fa622c0c1b26106ae96895d82.1400049817.git.hutao@cn.fujitsu.com> X-Mailer: git-send-email 1.8.5.2.229.g4448466 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.167.226.102] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Paolo Bonzini , Igor Mammedov Subject: [Qemu-devel] [PATCH v3.2 31/31] 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 | 36 ++++++++++++++++++++++++++++++++++++ hmp.h | 1 + monitor.c | 7 +++++++ 3 files changed, 44 insertions(+) diff --git a/hmp.c b/hmp.c index 5c4d612..1d5bf2d 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" @@ -1671,3 +1673,37 @@ 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; + int i = 0; + + + while (m) { + ov = string_output_visitor_new(false); + 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, " merge: %s\n", + m->value->merge ? "true" : "false"); + monitor_printf(mon, " dump: %s\n", + m->value->dump ? "true" : "false"); + monitor_printf(mon, " prealloc: %s\n", + m->value->prealloc ? "true" : "false"); + monitor_printf(mon, " policy: %s\n", + HostMemPolicy_lookup[m->value->policy]); + monitor_printf(mon, " host nodes: %s\n", + string_output_get_string(ov)); + + string_output_visitor_cleanup(ov); + m = m->next; + i++; + } + + monitor_printf(mon, "\n"); +} diff --git a/hmp.h b/hmp.h index 20ef454..bc13aae 100644 --- a/hmp.h +++ b/hmp.h @@ -97,5 +97,6 @@ void object_add_completion(ReadLineState *rs, int nb_args, const char *str); void object_del_completion(ReadLineState *rs, int nb_args, const char *str); void device_add_completion(ReadLineState *rs, int nb_args, const char *str); void device_del_completion(ReadLineState *rs, int nb_args, const char *str); +void hmp_info_memdev(Monitor *mon, const QDict *qdict); #endif diff --git a/monitor.c b/monitor.c index 4a3d3dd..4c24696 100644 --- a/monitor.c +++ b/monitor.c @@ -2958,6 +2958,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, }, };