From patchwork Tue Jun 10 11:15:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 357873 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 B84441400B2 for ; Tue, 10 Jun 2014 21:21:41 +1000 (EST) Received: from localhost ([::1]:38440 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuK7X-0000hi-DO for incoming@patchwork.ozlabs.org; Tue, 10 Jun 2014 07:21:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuK4C-0004nG-Dk for qemu-devel@nongnu.org; Tue, 10 Jun 2014 07:18:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WuK45-00029X-JL for qemu-devel@nongnu.org; Tue, 10 Jun 2014 07:18:12 -0400 Received: from [59.151.112.132] (port=5133 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuK44-0001xy-Oq for qemu-devel@nongnu.org; Tue, 10 Jun 2014 07:18:05 -0400 X-IronPort-AV: E=Sophos;i="4.98,1008,1392134400"; d="scan'208";a="31707557" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 10 Jun 2014 19:15:26 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s5ABI3Px027462; Tue, 10 Jun 2014 19:18:03 +0800 Received: from G08FNSTD100614.fnst.cn.fujitsu.com (10.167.226.102) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 10 Jun 2014 19:18:06 +0800 From: Hu Tao To: Date: Tue, 10 Jun 2014 19:15:29 +0800 Message-ID: <90c02321ea4add02d6ed8359919894aed6b0a3a6.1402397894.git.hutao@cn.fujitsu.com> X-Mailer: git-send-email 1.9.3 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: Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , Igor Mammedov , Yasunori Goto Subject: [Qemu-devel] [PATCH v5 16/16] qmp: add query-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 Add qmp command query-memdev to query for information of memory devices Signed-off-by: Hu Tao --- numa.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ qapi-schema.json | 40 +++++++++++++++++++++++++++++++ qmp-commands.hx | 38 ++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+) diff --git a/numa.c b/numa.c index 8ba5a38..ce9382d 100644 --- a/numa.c +++ b/numa.c @@ -31,9 +31,14 @@ #include "qapi-visit.h" #include "qapi/opts-visitor.h" #include "qapi/dealloc-visitor.h" +#include "qapi/qmp-output-visitor.h" +#include "qapi/qmp-input-visitor.h" +#include "qapi/string-output-visitor.h" +#include "qapi/string-input-visitor.h" #include "qapi/qmp/qerror.h" #include "hw/boards.h" #include "sysemu/hostmem.h" +#include "qmp-commands.h" QemuOptsList qemu_numa_opts = { .name = "numa", @@ -280,3 +285,70 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, addr += size; } } + +MemdevList *qmp_query_memdev(Error **errp) +{ + MemdevList *list = NULL, *m; + HostMemoryBackend *backend; + Error *err = NULL; + int i; + + for (i = 0; i < nb_numa_nodes; i++) { + backend = numa_info[i].node_memdev; + + m = g_malloc0(sizeof(*m)); + m->value = g_malloc0(sizeof(*m->value)); + m->value->size = object_property_get_int(OBJECT(backend), "size", + &err); + if (err) { + goto error; + } + + m->value->merge = object_property_get_bool(OBJECT(backend), "merge", + &err); + if (err) { + goto error; + } + + m->value->dump = object_property_get_bool(OBJECT(backend), "dump", + &err); + if (err) { + goto error; + } + + m->value->prealloc = object_property_get_bool(OBJECT(backend), + "prealloc", &err); + if (err) { + goto error; + } + + m->value->policy = object_property_get_enum(OBJECT(backend), + "policy", + HostMemPolicy_lookup, + &err); + if (err) { + goto error; + } + + object_property_get_uint16List(OBJECT(backend), "host-nodes", + &m->value->host_nodes, &err); + if (err) { + goto error; + } + + m->next = list; + list = m; + } + + return list; + +error: + while (list) { + m = list; + list = list->next; + g_free(m->value); + g_free(m); + } + qerror_report_err(err); + return NULL; +} diff --git a/qapi-schema.json b/qapi-schema.json index 0898c00..c3eafcf 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4779,3 +4779,43 @@ ## { 'enum': 'HostMemPolicy', 'data': [ 'default', 'preferred', 'bind', 'interleave' ] } + +## +# @Memdev: +# +# Information of memory device +# +# @size: memory device size +# +# @merge: enables or disables memory merge support +# +# @dump: includes memory device's memory in a core dump or not +# +# @prealloc: enables or disables memory preallocation +# +# @host-nodes: host nodes for its memory policy +# +# @policy: memory policy of memory device +# +# Since: 2.1 +## + +{ 'type': 'Memdev', + 'data': { + 'size': 'size', + 'merge': 'bool', + 'dump': 'bool', + 'prealloc': 'bool', + 'host-nodes': ['uint16'], + 'policy': 'HostMemPolicy' }} + +## +# @query-memdev: +# +# Returns information for all memory devices. +# +# Returns: a list of @Memdev. +# +# Since: 2.1 +## +{ 'command': 'query-memdev', 'returns': ['Memdev'] } diff --git a/qmp-commands.hx b/qmp-commands.hx index d8aa4ed..bb34cd8 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3572,3 +3572,41 @@ Example: } } ] } EQMP + + { + .name = "query-memdev", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_memdev, + }, + +SQMP +query-memdev +------------ + +Show memory devices information. + + +Example (1): + +-> { "execute": "query-memdev" } +<- { "return": [ + { + "size": 536870912, + "merge": false, + "dump": true, + "prealloc": false, + "host-nodes": [0, 1], + "policy": "bind" + }, + { + "size": 536870912, + "merge": false, + "dump": true, + "prealloc": true, + "host-nodes": [2, 3], + "policy": "preferred" + } + ] + } + +EQMP