From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFLKo-0004WL-Vt for qemu-devel@nongnu.org; Tue, 21 Jun 2016 09:03:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFLKh-0007gS-FI for qemu-devel@nongnu.org; Tue, 21 Jun 2016 09:03:18 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:61372 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFLKh-0007gD-Aq for qemu-devel@nongnu.org; Tue, 21 Jun 2016 09:03:11 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u5LCxRFa000867 for ; Tue, 21 Jun 2016 09:03:11 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 23n25wm3wa-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 21 Jun 2016 09:03:11 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 21 Jun 2016 14:03:09 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id A2BE12190046 for ; Tue, 21 Jun 2016 14:02:37 +0100 (BST) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u5LD36i26554018 for ; Tue, 21 Jun 2016 13:03:06 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u5LC38Yq018130 for ; Tue, 21 Jun 2016 06:03:09 -0600 From: David Hildenbrand Date: Tue, 21 Jun 2016 15:02:28 +0200 In-Reply-To: <1466514153-85777-1-git-send-email-dahi@linux.vnet.ibm.com> References: <1466514153-85777-1-git-send-email-dahi@linux.vnet.ibm.com> Message-Id: <1466514153-85777-24-git-send-email-dahi@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC 23/28] qmp: add QMP interface "query-cpu-model-expansion" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: ehabkost@redhat.com, jdenemar@redhat.com, imammedo@redhat.com, cornelia.huck@de.ibm.com, borntraeger@de.ibm.com, fiuczy@linux.vnet.ibm.com, mimu@linux.vnet.ibm.com Let's provide a standardized interface to expand CPU models, like the host model. To take care of all architectures, different detail levels for an expansion are introduced. Certain architectures might not support all detail levels. When the host CPU model is to be expanded, at least the accelerator QEMU has been started with affects the result. Some architectures might decide to take the QEMU machine also into account. E.g. for s390x, the host CPU model will only depend on the accelerator. The result of "stable" will be a migration safe CPU model, that will produce the same guest ABI on other QEMU versions. This interface is very helpful when CPU models are to be updated between QEMU versions. The updated model can then simply be expanded to a migration safe representation. Acked-by: Cornelia Huck Signed-off-by: David Hildenbrand --- include/sysemu/arch_init.h | 3 ++ qapi-schema.json | 81 ++++++++++++++++++++++++++++++++++ qmp-commands.hx | 6 +++ qmp.c | 7 +++ stubs/Makefile.objs | 1 + stubs/arch-query-cpu-model-expansion.c | 12 +++++ 6 files changed, 110 insertions(+) create mode 100644 stubs/arch-query-cpu-model-expansion.c diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h index d690dfa..37b2e86 100644 --- a/include/sysemu/arch_init.h +++ b/include/sysemu/arch_init.h @@ -35,5 +35,8 @@ int kvm_available(void); int xen_available(void); CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp); +CpuModelExpansionInfo *arch_query_cpu_model_expansion(CpuModelExpansionType type, + CpuModelInfo *mode, + Error **errp); #endif diff --git a/qapi-schema.json b/qapi-schema.json index 0964eec..5b72dc0 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3026,6 +3026,87 @@ ## { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] } +## +# @CpuModelInfo: +# +# Virtual CPU model. +# +# A CPU model consists of the name of a CPU definition, to which +# delta changes are applied (e.g. features added/removed). Most magic values +# that an architecture might require should be hidden behind the name. +# However, if required, architectures can expose relevant properties. +# +# @name: the name of the CPU definition the model is based on +# @props: #optional a dictionary of properties to be applied +# +# Since: 2.7.0 +## +{ 'struct': 'CpuModelInfo', + 'data': { 'name': 'str', + '*props': 'any' } } + +## +# @CpuModelExpansionType +# +# An enumeration of CPU model expansion types. +# +# @stable: Expand to a stable CPU model, creating a migration-safe +# representation with only delta changes. +# +# @migratable: Expand all migratable properties, hiding unmigratable +# properties. +# +# @full: Expand all properties, including unmigratable ones. +# +# Since: 2.7.0 +## +{ 'enum': 'CpuModelExpansionType', + 'data': [ 'stable', 'migratable', 'full' ] } + + +## +# @CpuModelExpansionInfo +# +# The result of a cpu model expansion. +# +# @model: the expanded CpuModelInfo. +# +# Since: 2.7.0 +## +{ 'struct': 'CpuModelExpansionInfo', + 'data': { 'model': 'CpuModelInfo' } } + + +## +# @query-cpu-model-expansion: +# +# Expands the given CPU model to the requested detail level. +# For "stable", a migration-safe representation is created, which will look +# the same on all QEMU versions and only contains delta changes. "migratable" +# and "full" will expose properties in a more detailed way. Not all types +# might be supported for an architecture. +# +# Expanding CPU models is in general independant of the accelerator, except +# for models like "host" that explicitly rely on an accelerator and can +# vary in different configurations. On certain architectures, the result may +# rely on the QEMU machine. +# +# This interface can therefore also be used to query the "host" capabilities +# on supporting architectures. +# +# Returns: a CpuModelExpansionInfo. Returns an error if CPU models are not +# supported, if the model cannot be expanded, if the model contains +# an unknown cpu definition name, unknown properties or properties +# with a wrong type. Also returns an error if an expansion type is +# not supported. +# +# Since: 2.7.0 +## +{ 'command': 'query-cpu-model-expansion', + 'data': { 'type': 'CpuModelExpansionType', + 'model': 'CpuModelInfo' }, + 'returns': 'CpuModelExpansionInfo' } + # @AddfdInfo: # # Information about a file descriptor that was added to an fd set. diff --git a/qmp-commands.hx b/qmp-commands.hx index b444c20..b279fc5 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3930,6 +3930,12 @@ EQMP }, { + .name = "query-cpu-model-expansion", + .args_type = "model:q", + .mhandler.cmd_new = qmp_marshal_query_cpu_model_expansion, + }, + + { .name = "query-target", .args_type = "", .mhandler.cmd_new = qmp_marshal_query_target, diff --git a/qmp.c b/qmp.c index 7df6543..c54f0a0 100644 --- a/qmp.c +++ b/qmp.c @@ -607,6 +607,13 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) return arch_query_cpu_definitions(errp); } +CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, + CpuModelInfo *model, + Error **errp) +{ + return arch_query_cpu_model_expansion(type, 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 4b258a6..83915f5 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-model-expansion.o stub-obj-y += bdrv-next-monitor-owned.o stub-obj-y += blk-commit-all.o stub-obj-y += blockdev-close-all-bdrv-states.o diff --git a/stubs/arch-query-cpu-model-expansion.c b/stubs/arch-query-cpu-model-expansion.c new file mode 100644 index 0000000..ae7cf55 --- /dev/null +++ b/stubs/arch-query-cpu-model-expansion.c @@ -0,0 +1,12 @@ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "sysemu/arch_init.h" +#include "qapi/qmp/qerror.h" + +CpuModelExpansionInfo *arch_query_cpu_model_expansion(CpuModelExpansionType type, + CpuModelInfo *mode, + Error **errp) +{ + error_setg(errp, QERR_UNSUPPORTED); + return NULL; +} -- 2.6.6