From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwxO1-0008Io-Rj for qemu-devel@nongnu.org; Tue, 17 Jun 2014 13:41:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwxNw-00053g-EY for qemu-devel@nongnu.org; Tue, 17 Jun 2014 13:41:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29105) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwxNw-00053V-0t for qemu-devel@nongnu.org; Tue, 17 Jun 2014 13:41:28 -0400 Date: Tue, 17 Jun 2014 20:41:48 +0300 From: "Michael S. Tsirkin" Message-ID: <1403021756-15960-90-git-send-email-mst@redhat.com> References: <1403021756-15960-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1403021756-15960-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 089/103] hmp: add info memdev List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , Anthony Liguori , Hu Tao , Luiz Capitulino , Hani Benhabiles , Stefan Hajnoczi , Igor Mammedov From: Hu Tao This is the hmp counterpart of qmp query-memdev. Signed-off-by: Hu Tao Signed-off-by: Michael S. Tsirkin Acked-by: Michael S. Tsirkin MST: fix build on 32 bit --- hmp.h | 1 + hmp.c | 36 ++++++++++++++++++++++++++++++++++++ monitor.c | 7 +++++++ 3 files changed, 44 insertions(+) diff --git a/hmp.h b/hmp.h index aba59e9..85fb860 100644 --- a/hmp.h +++ b/hmp.h @@ -93,6 +93,7 @@ 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); 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); diff --git a/hmp.c b/hmp.c index ccc35d4..41006f5 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" @@ -1676,3 +1678,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: %" PRId64 "\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/monitor.c b/monitor.c index a2a4466..c270fd8 100644 --- a/monitor.c +++ b/monitor.c @@ -2959,6 +2959,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, }, }; -- MST