As the work to get X86CPU subclasses static properties defined is taking very
long to get reviewed and we risk not getting it finished in 1.5, I am sending
an alternative mechanism to allow libvirt to probe for CPU model information.
It's interesting to note that this alternative solution is actually _easier_ to
use for libvirt, because libvirt logic is already based on CPUID bit values, not
"feature names", so it should be very easy to convert the current libvirt code
that (incorrectly) query the host CPU directly for available features to instead
start QEMU with "-cpu host" and use the "feature-words" array
information to
find out which CPU features are supported by the host.
The property will have two main use cases:
- Checking host capabilities, by checking the features of the "host"
CPU model;
- Checking which features are enabled on each CPU model.
This series has two alternative implementations, so both approaches can get
feedback: patch 3 has a non-qapi implementation, that simply builds the list and
sets the struct fields manually. Patch 4 converts that implementation to a qapi-
based implementation.
(BTW, I really missed some documentation on the list-related visitor functions,
when writing this code)
Example output:
$ ./QMP/qmp --path=/tmp/m qom-get --path=/machine/unattached/device[1]
--property=feature-words
item[0].cpuid-register: EDX
item[0].cpuid-input-eax: 1
item[0].features: 126614521
item[1].cpuid-register: ECX
item[1].cpuid-input-eax: 1
item[1].features: 2155880449
item[2].cpuid-register: EBX
item[2].cpuid-input-eax: 7
item[2].features: 0
item[2].cpuid-input-ecx: 0
item[3].cpuid-register: EDX
item[3].cpuid-input-eax: 2147483649
item[3].features: 563346425
item[4].cpuid-register: ECX
item[4].cpuid-input-eax: 2147483649
item[4].features: 101
item[5].cpuid-register: EDX
item[5].cpuid-input-eax: 3221225473
item[5].features: 0
item[6].cpuid-register: EAX
item[6].cpuid-input-eax: 1073741825
item[6].features: 0
item[7].cpuid-register: EDX
item[7].cpuid-input-eax: 2147483658
item[7].features: 0
I plan to send another RFC as followup soon, that will add:
* "-cpu force" (or "nofilter", or something else; I haven't
decided about the
name, yet) flag, to disable feature filtering based on host capabilities.
* "filtered-features" property, listing which features were filtered out
because of missing host capabilities (to allow libvirt to implement
"enforce"
mode in a more reliable way).
Eduardo Habkost (4):
target-i386: Add ECX information to FeatureWordInfo
target-i386: Move feature word array outside get_register_name_32()
target-i386: Add "feature-words" property
target-i386: Use qapi for x86_cpu_get_feature_words()
.gitignore | 2 +
Makefile | 11 +++++
Makefile.objs | 5 +++
cpu-qapi-schema.json | 31 ++++++++++++++
target-i386/Makefile.objs | 1 +
target-i386/cpu-qapi-schema.json | 31 ++++++++++++++
target-i386/cpu.c | 92 +++++++++++++++++++++++++++++++++-------
7 files changed, 158 insertions(+), 15 deletions(-)
create mode 100644 cpu-qapi-schema.json
create mode 100644 target-i386/cpu-qapi-schema.json
--
1.8.1.4