From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkECC-0007FM-9L for qemu-devel@nongnu.org; Tue, 13 May 2014 11:00:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkEC0-0002hV-RF for qemu-devel@nongnu.org; Tue, 13 May 2014 11:00:44 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:52762) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkEC0-0002gd-JD for qemu-devel@nongnu.org; Tue, 13 May 2014 11:00:32 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 May 2014 16:00:31 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 6BF2F1B0805F for ; Tue, 13 May 2014 16:00:43 +0100 (BST) Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s4DF0TBN59965458 for ; Tue, 13 May 2014 15:00:29 GMT Received: from d06av09.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s4DF0SwP007706 for ; Tue, 13 May 2014 09:00:29 -0600 From: Michael Mueller Date: Tue, 13 May 2014 17:00:21 +0200 Message-Id: <1399993222-16339-10-git-send-email-mimu@linux.vnet.ibm.com> In-Reply-To: <1399993222-16339-1-git-send-email-mimu@linux.vnet.ibm.com> References: <1399993222-16339-1-git-send-email-mimu@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v1 RFC 09/10] QEMU: s390: cpu model QMP query-cpu-model List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Cc: mimu@linux.vnet.ibm.com, Gleb Natapov , Alexander Graf , Christian Borntraeger , "Jason J. Herne" , Cornelia Huck , Paolo Bonzini , Andreas Faerber , Richard Henderson This patch implements a new QMP request named "query-cpu-model". It returns the cpu model of cpu 0. eg: request: '{"execute" : "query-cpu-model" } answer: '{"return" : {"name": "2827-ga2"}} Alias names are resolved to their respective machine type and GA names already during cpu instantiation. Thus, also a cpu name like "host", which is implemented as alias, will return its normalized cpu model name. Signed-off-by: Michael Mueller Acked-by: Cornelia Huck --- include/sysemu/arch_init.h | 1 + qapi-schema.json | 23 +++++++++++++++++++++++ qmp-commands.hx | 6 ++++++ qmp.c | 5 +++++ stubs/Makefile.objs | 1 + stubs/arch-query-cpu-mod.c | 9 +++++++++ target-s390x/cpu.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 87 insertions(+) create mode 100644 stubs/arch-query-cpu-mod.c diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h index cadcedc..dcdb1ed 100644 --- a/include/sysemu/arch_init.h +++ b/include/sysemu/arch_init.h @@ -38,5 +38,6 @@ int xen_available(void); bool cpudesc_avail(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 36cb964..0a95f7b 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3460,6 +3460,29 @@ ## { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] } +## +# @CpuModelInfo: +# +# Virtual CPU model definition. +# +# @name: the name of the CPU model definition +# +# Since: 2.1.0 +## +{ 'type': 'CpuModelInfo', + 'data': { 'name': 'str' } } + +## +# @query-cpu-model: +# +# Return to current virtual CPU model +# +# Returns: CpuModelInfo +# +# Since: 2.1.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 cae890e..e56d3a9 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3247,6 +3247,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 a7f432b..1903db1 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/stubs/Makefile.objs b/stubs/Makefile.objs index d99e2b9..f6db116 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -1,4 +1,5 @@ stub-obj-y += arch-query-cpu-def.o +stub-obj-y += arch-query-cpu-mod.o stub-obj-y += clock-warp.o stub-obj-y += cpu-get-clock.o stub-obj-y += cpu-get-icount.o diff --git a/stubs/arch-query-cpu-mod.c b/stubs/arch-query-cpu-mod.c new file mode 100644 index 0000000..90ebd08 --- /dev/null +++ b/stubs/arch-query-cpu-mod.c @@ -0,0 +1,9 @@ +#include "qemu-common.h" +#include "sysemu/arch_init.h" +#include "qapi/qmp/qerror.h" + +CpuModelInfo *arch_query_cpu_model(Error **errp) +{ + error_set(errp, QERR_UNSUPPORTED); + return NULL; +} diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index 6479659..132b468 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -37,6 +37,8 @@ #define CR0_RESET 0xE0UL #define CR14_RESET 0xC2000000UL; +#define CPU_MODEL_NAME_LEN 32 + #ifdef CONFIG_KVM typedef struct CpuDefinition { CpuDefinitionInfoList *head; @@ -171,6 +173,46 @@ out_name: out_info: return NULL; } + +CpuModelInfo *arch_query_cpu_model(Error **errp) +{ + CpuModelInfo *cpu_model; + S390CPUClass *cc; + S390CPU *cpu; + + cpu = s390_cpu_addr2state(0); + if (!cpu) { + goto out_no_cpu; + } + cc = S390_CPU_GET_CLASS(cpu); + if (!cc) { + goto out_no_cpu; + } + if (!cc->proc->type) { + goto out_no_cpu; + } + cpu_model = g_try_malloc0(sizeof(*cpu_model)); + if (!cpu_model) { + goto out_no_mem; + } + cpu_model->name = g_try_malloc0(CPU_MODEL_NAME_LEN); + if (!cpu_model->name) { + goto out_no_mem; + } + snprintf(cpu_model->name, CPU_MODEL_NAME_LEN - 1, "%04x-ga%u", + cc->proc->type, cc->mach->ga); + if (s390_use_sofl) { + strncat(cpu_model->name, ",+sofl", CPU_MODEL_NAME_LEN - 1); + } + return cpu_model; + +out_no_mem: + if (cpu_model) { + g_free(cpu_model); + } +out_no_cpu: + return NULL; +} #endif static void s390_cpu_set_pc(CPUState *cs, vaddr value) -- 1.8.3.1