Message ID | 1466453564-7572-2-git-send-email-ehabkost@redhat.com |
---|---|
State | New |
Headers | show |
On 06/20/2016 02:12 PM, Eduardo Habkost wrote: > The command can be used to return host-specific CPU capabilities > information. > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > --- > include/sysemu/arch_init.h | 1 + > qapi-schema.json | 36 ++++++++++++++++++++++++++++++++++++ > qmp-commands.hx | 6 ++++++ > qmp.c | 13 +++++++++++++ > stubs/Makefile.objs | 1 + > stubs/arch-query-host-cpu-info.c | 8 ++++++++ > 6 files changed, 65 insertions(+) > create mode 100644 stubs/arch-query-host-cpu-info.c > > diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h > index d690dfa..54215ab 100644 > --- a/include/sysemu/arch_init.h > +++ b/include/sysemu/arch_init.h > @@ -35,5 +35,6 @@ int kvm_available(void); > int xen_available(void); > > CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp); > +void arch_query_host_cpu_info(HostCPUInfo *r, bool migratable, Error **errp); > > #endif > diff --git a/qapi-schema.json b/qapi-schema.json > index 19e3ef2..d2f4879 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -3047,6 +3047,42 @@ > ## > { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] } > > + > +## > +# @HostCPUInfo: > +# > +# Information on CPU capabilities supported by the current host. > +# > +# @qom-properties: #optional Values of CPU QOM properties corresponding > +# to CPU capabilities supported by the host. > +# > +# Most properties returned in qom-properties are boolean properties > +# indicating if a feature can be enabled in the current host. Other > +# non-boolean properties may be returned, the semantics of each property > +# depend on the architecture-specific code that handle them. > +# > +# Since: 2.7.0 Most places in .json files list just 'Since: x.y' rather than 'x.y.z', but we aren't consistent enough to insist either way on including or excluding a micro release number. > +## > +{ 'struct': 'HostCPUInfo', > + 'data': { '*qom-properties': 'any' } } This is a big hammer that makes the properties non-introspectible - a client can tell that properties will be returned, but cannot tell which properties to expect nor what format to expect for a given property name. I don't know that the interface could be made easily introspectible or not (it would probably require some QAPI unions, and a LOT more generated code). So it would be nice if we could explore how hard it would be to use a type-safe representation instead of 'any', before declaring that this is the best we can do. Or, it may be the sign of a bigger issue that we have no good way to introspect what qom properties to expect, in general (and that solving that would also solve this). > + > +## > +# @query-host-cpu: > +# > +# @migratable: #optional If false, unmigratable features will be > +# returned as well. If true, only migratable features > +# will be returned. Defaults to true. > +# > +# Return information about CPU capabilities in the current host. > +# The returned data may depend on machine and accelerator configuration. > +# > +# Returns: A HostCPUInfo object. > +# > +# Since: 2.7.0 > +## > +{ 'command': 'query-host-cpu', 'data': { '*migratable': 'bool' }, > + 'returns': 'HostCPUInfo' } > + > # @AddfdInfo:
On Tue, Jun 21, 2016 at 03:48:58PM -0600, Eric Blake wrote: > On 06/20/2016 02:12 PM, Eduardo Habkost wrote: > > The command can be used to return host-specific CPU capabilities > > information. > > > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > > --- > > include/sysemu/arch_init.h | 1 + > > qapi-schema.json | 36 ++++++++++++++++++++++++++++++++++++ > > qmp-commands.hx | 6 ++++++ > > qmp.c | 13 +++++++++++++ > > stubs/Makefile.objs | 1 + > > stubs/arch-query-host-cpu-info.c | 8 ++++++++ > > 6 files changed, 65 insertions(+) > > create mode 100644 stubs/arch-query-host-cpu-info.c > > > > diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h > > index d690dfa..54215ab 100644 > > --- a/include/sysemu/arch_init.h > > +++ b/include/sysemu/arch_init.h > > @@ -35,5 +35,6 @@ int kvm_available(void); > > int xen_available(void); > > > > CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp); > > +void arch_query_host_cpu_info(HostCPUInfo *r, bool migratable, Error **errp); > > > > #endif > > diff --git a/qapi-schema.json b/qapi-schema.json > > index 19e3ef2..d2f4879 100644 > > --- a/qapi-schema.json > > +++ b/qapi-schema.json > > @@ -3047,6 +3047,42 @@ > > ## > > { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] } > > > > + > > +## > > +# @HostCPUInfo: > > +# > > +# Information on CPU capabilities supported by the current host. > > +# > > +# @qom-properties: #optional Values of CPU QOM properties corresponding > > +# to CPU capabilities supported by the host. > > +# > > +# Most properties returned in qom-properties are boolean properties > > +# indicating if a feature can be enabled in the current host. Other > > +# non-boolean properties may be returned, the semantics of each property > > +# depend on the architecture-specific code that handle them. > > +# > > +# Since: 2.7.0 > > Most places in .json files list just 'Since: x.y' rather than 'x.y.z', > but we aren't consistent enough to insist either way on including or > excluding a micro release number. > > > +## > > +{ 'struct': 'HostCPUInfo', > > + 'data': { '*qom-properties': 'any' } } > > This is a big hammer that makes the properties non-introspectible - a > client can tell that properties will be returned, but cannot tell which > properties to expect nor what format to expect for a given property > name. I don't know that the interface could be made easily > introspectible or not (it would probably require some QAPI unions, and a > LOT more generated code). So it would be nice if we could explore how > hard it would be to use a type-safe representation instead of 'any', > before declaring that this is the best we can do. Or, it may be the > sign of a bigger issue that we have no good way to introspect what qom > properties to expect, in general (and that solving that would also solve > this). What I thought libvirt needed is different from what I though, so this series will be dropped by now (see the "s390x CPU models: exposing features" thread). But your comments may still apply when we look at the alternative "query-cpu-model-expansion" proposal. I believe QOM introspection is really the issue here. The CPU configuration is already based on QOM properties. Manually duplicating the existing QOM properties into the QAPI representation would be a waste of time, IMO. But I agree that the interface could be improved: we should document very clearly what can be done with the QOM property list being returned, and return only useful data. For example: we could only return properties that really makes sense when used with "-cpu" or "-global" (not every single QOM property), and document that.
diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h index d690dfa..54215ab 100644 --- a/include/sysemu/arch_init.h +++ b/include/sysemu/arch_init.h @@ -35,5 +35,6 @@ int kvm_available(void); int xen_available(void); CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp); +void arch_query_host_cpu_info(HostCPUInfo *r, bool migratable, Error **errp); #endif diff --git a/qapi-schema.json b/qapi-schema.json index 19e3ef2..d2f4879 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3047,6 +3047,42 @@ ## { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] } + +## +# @HostCPUInfo: +# +# Information on CPU capabilities supported by the current host. +# +# @qom-properties: #optional Values of CPU QOM properties corresponding +# to CPU capabilities supported by the host. +# +# Most properties returned in qom-properties are boolean properties +# indicating if a feature can be enabled in the current host. Other +# non-boolean properties may be returned, the semantics of each property +# depend on the architecture-specific code that handle them. +# +# Since: 2.7.0 +## +{ 'struct': 'HostCPUInfo', + 'data': { '*qom-properties': 'any' } } + +## +# @query-host-cpu: +# +# @migratable: #optional If false, unmigratable features will be +# returned as well. If true, only migratable features +# will be returned. Defaults to true. +# +# Return information about CPU capabilities in the current host. +# The returned data may depend on machine and accelerator configuration. +# +# Returns: A HostCPUInfo object. +# +# Since: 2.7.0 +## +{ 'command': 'query-host-cpu', 'data': { '*migratable': 'bool' }, + 'returns': 'HostCPUInfo' } + # @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..d4c2ccd 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3930,6 +3930,12 @@ EQMP }, { + .name = "query-host-cpu", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_query_host_cpu, + }, + + { .name = "query-target", .args_type = "", .mhandler.cmd_new = qmp_marshal_query_target, diff --git a/qmp.c b/qmp.c index 7df6543..aec24d5 100644 --- a/qmp.c +++ b/qmp.c @@ -607,6 +607,19 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) return arch_query_cpu_definitions(errp); } +HostCPUInfo *qmp_query_host_cpu(bool has_migratable, bool migratable, + Error **errp) +{ + HostCPUInfo *r = g_new0(HostCPUInfo, 1); + + if (!has_migratable) { + migratable = true; + } + + arch_query_host_cpu_info(r, migratable, errp); + return r; +} + 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..eae0e89 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-host-cpu-info.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-host-cpu-info.c b/stubs/arch-query-host-cpu-info.c new file mode 100644 index 0000000..b0c455c --- /dev/null +++ b/stubs/arch-query-host-cpu-info.c @@ -0,0 +1,8 @@ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "sysemu/arch_init.h" +#include "qapi/qmp/qerror.h" + +void arch_query_host_cpu_info(HostCPUInfo *r, bool migratable, Error **errp) +{ +}
The command can be used to return host-specific CPU capabilities information. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- include/sysemu/arch_init.h | 1 + qapi-schema.json | 36 ++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 6 ++++++ qmp.c | 13 +++++++++++++ stubs/Makefile.objs | 1 + stubs/arch-query-host-cpu-info.c | 8 ++++++++ 6 files changed, 65 insertions(+) create mode 100644 stubs/arch-query-host-cpu-info.c