From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRKgu-0000Ys-Vs for qemu-devel@nongnu.org; Wed, 02 Oct 2013 07:34:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VRKgm-00027c-1j for qemu-devel@nongnu.org; Wed, 02 Oct 2013 07:34:04 -0400 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:54477) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRKgl-00027K-B8 for qemu-devel@nongnu.org; Wed, 02 Oct 2013 07:33:55 -0400 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 2 Oct 2013 12:33:54 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9CC7117D8059 for ; Wed, 2 Oct 2013 12:34:09 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r92BXdbE50331732 for ; Wed, 2 Oct 2013 11:33:39 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r92BXpr1023001 for ; Wed, 2 Oct 2013 05:33:51 -0600 From: Michael Mueller Date: Wed, 2 Oct 2013 13:33:41 +0200 Message-Id: <1380713622-22325-11-git-send-email-mimu@linux.vnet.ibm.com> In-Reply-To: <1380713622-22325-1-git-send-email-mimu@linux.vnet.ibm.com> References: <1380713622-22325-1-git-send-email-mimu@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH RFC 10/11] s390/qemu: cpu model QMP query-cpu-model List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Michael Mueller This patch implements a new QMP request named "cpu-model". It returns the cpu model of cpu 0. eg: request: '{"execute" : "query-cpu-model" } answer: '{"return" : "2817-ga1" } Alias names are resolved to their respactive machine type and GA names already during cpu instantiation. Thus, also a cpu name like "host", which is iplemented as alias, will return its normalized cpu model name. Signed-off-by: Michael Mueller --- include/sysemu/arch_init.h | 1 + qapi-schema.json | 23 +++++++++++++++++++++++ qmp-commands.hx | 6 ++++++ qmp.c | 5 +++++ target-s390x/cpu.c | 21 +++++++++++++++++++++ 5 files changed, 56 insertions(+) diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h index be71bca..a8d623b 100644 --- a/include/sysemu/arch_init.h +++ b/include/sysemu/arch_init.h @@ -36,5 +36,6 @@ int kvm_available(void); int xen_available(void); CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp); +CpuModelInfo *arch_query_cpu_model(Error **errp); #endif diff --git a/qapi-schema.json b/qapi-schema.json index 145eca8..9e86186 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3129,6 +3129,29 @@ ## { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] } +## +# @CpuModelInfo: +# +# Virtual CPU model definition. +# +# @name: the name of the CPU model definition +# +# Since: 1.x.0 +## +{ 'type': 'CpuModelInfo', + 'data': { 'name': 'str' } } + +## +# @query-cpu-model: +# +# Return to current virtual CPU model +# +# Returns: CpuModelInfo +# +# Since: 1.2.0 +## +{ 'command': 'query-cpu-model', 'returns': 'CpuModelInfo' } + # @AddfdInfo: # # Information about a file descriptor that was added to an fd set. diff --git a/qmp-commands.hx b/qmp-commands.hx index b17c46e..fef83a4 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3036,6 +3036,12 @@ EQMP }, { + .name = "query-cpu-model", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_cpu_model, + }, + + { .name = "query-target", .args_type = "", .mhandler.cmd_new = qmp_marshal_input_query_target, diff --git a/qmp.c b/qmp.c index 4c149b3..d9b1921 100644 --- a/qmp.c +++ b/qmp.c @@ -486,6 +486,11 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) return arch_query_cpu_definitions(errp); } +CpuModelInfo *qmp_query_cpu_model(Error **errp) +{ + return arch_query_cpu_model(errp); +} + void qmp_add_client(const char *protocol, const char *fdname, bool has_skipauth, bool skipauth, bool has_tls, bool tls, Error **errp) diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index b790905..605c124 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -129,6 +129,27 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) return entry; } } + +CpuModelInfo *arch_query_cpu_model(Error **errp) +{ + CpuModelInfo *cpu_model; + S390CPU *cpu; + + cpu = s390_cpu_addr2state(0); + if (!cpu) { + return NULL; + } + cpu_model = g_malloc0(sizeof(*cpu_model)); + if (!cpu_model) { + return NULL; + } + cpu_model->name = g_strdup(cpu->env.cpu_model_str); + if (!cpu_model->name) { + g_free(cpu_model); + return NULL; + } + return cpu_model; +} #endif static void s390_cpu_set_pc(CPUState *cs, vaddr value) -- 1.8.3.1