[libvirt] [PATCH 0/7] qemu: Report better host-model CPUs in domain caps

One of the main reasons for introducing host-model CPU definition in a domain capabilities XML was the inability to express disabled features in a host capabilities XML. That is, when a host CPU is, e.g., Haswell without x2apic support, host capabilities XML will have to report it as Westmere + a bunch of additional features., but we really want to use Haswell - x2apic when creating a host-model CPU. Unfortunately, I somehow forgot to do the last step and the code would just copy the CPU definition found in the host capabilities XML. This changed recently for new QEMU versions which allow us to query host CPU, but any slightly older QEMU will not benefit from any change I did. This patch makes sure the right CPU model is filled in the domain capabilities even with old QEMU. The issue was reported in https://bugzilla.redhat.com/show_bug.cgi?id=1426456 Jiri Denemark (7): Do not format <arch> in guest CPU XML cpu: Replace cpuNodeData with virCPUGetHost cpu: Add virCPUType parameter to virCPUGetHost cpu: Add list of allowed CPU models to virCPUGetHost qemu: Refactor virQEMUCapsInitCPU qemu: Report better host-model CPUs in domain caps cputest: New test for Intel Core i7-4510U src/bhyve/bhyve_capabilities.c | 35 +--- src/conf/cpu_conf.c | 2 +- src/cpu/cpu.c | 100 ++++++++-- src/cpu/cpu.h | 16 +- src/cpu/cpu_arm.c | 1 - src/cpu/cpu_ppc64.c | 30 +-- src/cpu/cpu_s390.c | 1 - src/cpu/cpu_x86.c | 29 ++- src/libvirt_private.syms | 2 +- src/qemu/qemu_capabilities.c | 61 +++---- src/qemu/qemu_capspriv.h | 5 + src/vmware/vmware_conf.c | 20 +- src/vz/vz_driver.c | 22 +-- tests/Makefile.am | 11 +- tests/cputest.c | 1 + tests/cputestdata/x86_64-cpuid-A10-5800K-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-A10-5800K-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Atom-D510-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Atom-N450-guest.xml | 1 - .../x86_64-cpuid-Core-i5-2500-guest.xml | 1 - .../cputestdata/x86_64-cpuid-Core-i5-2500-json.xml | 1 - .../x86_64-cpuid-Core-i5-2540M-guest.xml | 1 - .../x86_64-cpuid-Core-i5-2540M-json.xml | 1 - .../x86_64-cpuid-Core-i5-4670T-guest.xml | 1 - .../x86_64-cpuid-Core-i5-4670T-json.xml | 1 - .../x86_64-cpuid-Core-i5-6600-guest.xml | 1 - .../cputestdata/x86_64-cpuid-Core-i5-6600-json.xml | 1 - .../x86_64-cpuid-Core-i7-2600-guest.xml | 1 - .../cputestdata/x86_64-cpuid-Core-i7-2600-json.xml | 1 - .../x86_64-cpuid-Core-i7-3520M-guest.xml | 1 - .../x86_64-cpuid-Core-i7-3740QM-guest.xml | 1 - .../x86_64-cpuid-Core-i7-3740QM-json.xml | 1 - .../x86_64-cpuid-Core-i7-3770-guest.xml | 1 - .../cputestdata/x86_64-cpuid-Core-i7-3770-json.xml | 1 - .../x86_64-cpuid-Core-i7-4510U-guest.xml | 29 +++ .../x86_64-cpuid-Core-i7-4510U-host.xml | 44 +++++ .../x86_64-cpuid-Core-i7-4510U-json.xml | 15 ++ tests/cputestdata/x86_64-cpuid-Core-i7-4510U.json | 203 +++++++++++++++++++++ tests/cputestdata/x86_64-cpuid-Core-i7-4510U.xml | 34 ++++ .../x86_64-cpuid-Core-i7-4600U-guest.xml | 1 - .../x86_64-cpuid-Core-i7-4600U-json.xml | 1 - .../x86_64-cpuid-Core-i7-5600U-guest.xml | 1 - .../x86_64-cpuid-Core-i7-5600U-json.xml | 1 - .../cputestdata/x86_64-cpuid-Core2-E6850-guest.xml | 1 - .../cputestdata/x86_64-cpuid-Core2-E6850-json.xml | 1 - .../cputestdata/x86_64-cpuid-Core2-Q9500-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-FX-8150-guest.xml | 1 - .../x86_64-cpuid-Opteron-1352-guest.xml | 1 - .../x86_64-cpuid-Opteron-2350-guest.xml | 1 - .../cputestdata/x86_64-cpuid-Opteron-2350-json.xml | 1 - .../x86_64-cpuid-Opteron-6234-guest.xml | 1 - .../cputestdata/x86_64-cpuid-Opteron-6234-json.xml | 1 - .../x86_64-cpuid-Opteron-6282-guest.xml | 1 - .../x86_64-cpuid-Pentium-P6100-guest.xml | 1 - .../cputestdata/x86_64-cpuid-Phenom-B95-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Phenom-B95-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Xeon-5110-guest.xml | 1 - .../x86_64-cpuid-Xeon-E3-1245-guest.xml | 1 - .../cputestdata/x86_64-cpuid-Xeon-E3-1245-json.xml | 1 - .../x86_64-cpuid-Xeon-E5-2630-guest.xml | 1 - .../cputestdata/x86_64-cpuid-Xeon-E5-2630-json.xml | 1 - .../x86_64-cpuid-Xeon-E5-2650-guest.xml | 1 - .../cputestdata/x86_64-cpuid-Xeon-E5-2650-json.xml | 1 - .../x86_64-cpuid-Xeon-E7-4820-guest.xml | 1 - .../cputestdata/x86_64-cpuid-Xeon-E7-4820-json.xml | 1 - .../x86_64-cpuid-Xeon-E7-8890-guest.xml | 1 - .../cputestdata/x86_64-cpuid-Xeon-W3520-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Xeon-W3520-json.xml | 1 - .../cputestdata/x86_64-cpuid-Xeon-X5460-guest.xml | 1 - tests/domaincapstest.c | 6 + tests/qemucpumock.c | 35 ++++ tests/qemuxml2argvtest.c | 6 +- 72 files changed, 560 insertions(+), 197 deletions(-) create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-4510U-guest.xml create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-4510U-host.xml create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-4510U-json.xml create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-4510U.json create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-4510U.xml create mode 100644 tests/qemucpumock.c -- 2.12.0

This element is only allowed for host CPUs. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/conf/cpu_conf.c | 2 +- tests/cputestdata/x86_64-cpuid-A10-5800K-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-A10-5800K-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Atom-D510-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Atom-N450-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i5-2500-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i5-2500-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i5-2540M-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i5-2540M-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i5-4670T-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i5-4670T-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i5-6600-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i5-6600-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i7-2600-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i7-2600-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i7-3520M-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i7-3740QM-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i7-3740QM-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i7-3770-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i7-3770-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i7-4600U-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i7-4600U-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i7-5600U-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Core-i7-5600U-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Core2-E6850-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Core2-E6850-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Core2-Q9500-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-FX-8150-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Opteron-1352-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Opteron-2350-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Opteron-2350-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Opteron-6234-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Opteron-6234-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Opteron-6282-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Pentium-P6100-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Phenom-B95-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Phenom-B95-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Xeon-5110-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Xeon-E7-8890-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Xeon-W3520-guest.xml | 1 - tests/cputestdata/x86_64-cpuid-Xeon-W3520-json.xml | 1 - tests/cputestdata/x86_64-cpuid-Xeon-X5460-guest.xml | 1 - 50 files changed, 1 insertion(+), 50 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 1bcceeda4..2724fa30a 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -536,7 +536,7 @@ virCPUDefFormatBufFull(virBufferPtr buf, /* Format children */ virBufferAdjustIndent(&childrenBuf, indent + 2); - if (def->arch) + if (def->type == VIR_CPU_TYPE_HOST && def->arch) virBufferAsprintf(&childrenBuf, "<arch>%s</arch>\n", virArchToString(def->arch)); if (virCPUDefFormatBuf(&childrenBuf, def, updateCPU) < 0) diff --git a/tests/cputestdata/x86_64-cpuid-A10-5800K-guest.xml b/tests/cputestdata/x86_64-cpuid-A10-5800K-guest.xml index dacf1d0eb..98a95e1c4 100644 --- a/tests/cputestdata/x86_64-cpuid-A10-5800K-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-A10-5800K-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Opteron_G5</model> <vendor>AMD</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-A10-5800K-json.xml b/tests/cputestdata/x86_64-cpuid-A10-5800K-json.xml index c021fcddf..fa61b7b60 100644 --- a/tests/cputestdata/x86_64-cpuid-A10-5800K-json.xml +++ b/tests/cputestdata/x86_64-cpuid-A10-5800K-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Opteron_G5</model> <vendor>AMD</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Atom-D510-guest.xml b/tests/cputestdata/x86_64-cpuid-Atom-D510-guest.xml index 5e9efc7c0..caa0bfd53 100644 --- a/tests/cputestdata/x86_64-cpuid-Atom-D510-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Atom-D510-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>core2duo</model> <vendor>Intel</vendor> <feature policy='require' name='ds'/> diff --git a/tests/cputestdata/x86_64-cpuid-Atom-N450-guest.xml b/tests/cputestdata/x86_64-cpuid-Atom-N450-guest.xml index be11b887d..e8f5c9388 100644 --- a/tests/cputestdata/x86_64-cpuid-Atom-N450-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Atom-N450-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>core2duo</model> <vendor>Intel</vendor> <feature policy='require' name='ds'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i5-2500-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i5-2500-guest.xml index 4c249eb0c..22b5cf31f 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i5-2500-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i5-2500-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>SandyBridge</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i5-2500-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i5-2500-json.xml index 2e2430e78..c9ae65192 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i5-2500-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i5-2500-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>SandyBridge</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i5-2540M-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i5-2540M-guest.xml index 4c249eb0c..22b5cf31f 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i5-2540M-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i5-2540M-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>SandyBridge</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i5-2540M-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i5-2540M-json.xml index 2e2430e78..c9ae65192 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i5-2540M-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i5-2540M-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>SandyBridge</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i5-4670T-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i5-4670T-guest.xml index 70d13282b..0ccbcd062 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i5-4670T-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i5-4670T-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Haswell-noTSX</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i5-4670T-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i5-4670T-json.xml index 8d3a0b618..489de49fb 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i5-4670T-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i5-4670T-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Haswell-noTSX</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i5-6600-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i5-6600-guest.xml index 0ab5a7a7b..c3561d597 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i5-6600-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i5-6600-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Skylake-Client</model> <vendor>Intel</vendor> <feature policy='require' name='ds'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i5-6600-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i5-6600-json.xml index e768aa674..61a52212a 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i5-6600-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i5-6600-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Skylake-Client</model> <vendor>Intel</vendor> <feature policy='require' name='ss'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-2600-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-2600-guest.xml index 4c249eb0c..22b5cf31f 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i7-2600-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-2600-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>SandyBridge</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-2600-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-2600-json.xml index 4e721aba4..25c87e164 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i7-2600-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-2600-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>SandyBridge</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-3520M-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-3520M-guest.xml index 776001ff4..fa1a43a8a 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i7-3520M-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-3520M-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>IvyBridge</model> <vendor>Intel</vendor> <feature policy='require' name='ds'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-3740QM-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-3740QM-guest.xml index 90957e99d..d52f49d30 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i7-3740QM-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-3740QM-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>IvyBridge</model> <vendor>Intel</vendor> <feature policy='require' name='ds'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-3740QM-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-3740QM-json.xml index 03c22de4b..60086b8b1 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i7-3740QM-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-3740QM-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>IvyBridge</model> <vendor>Intel</vendor> <feature policy='require' name='ss'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-3770-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-3770-guest.xml index 776001ff4..fa1a43a8a 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i7-3770-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-3770-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>IvyBridge</model> <vendor>Intel</vendor> <feature policy='require' name='ds'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-3770-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-3770-json.xml index c1544afd3..1dc866dba 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i7-3770-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-3770-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>IvyBridge</model> <vendor>Intel</vendor> <feature policy='require' name='ss'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-4600U-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-4600U-guest.xml index b2aac64b2..42e7c9011 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i7-4600U-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-4600U-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Haswell-noTSX</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-4600U-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-4600U-json.xml index 8e4e9d96a..3ca3b0f24 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i7-4600U-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-4600U-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Haswell-noTSX</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-guest.xml index cd7b4bb8e..877895cf1 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Broadwell</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-json.xml index be11fa061..a736cdfb0 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-5600U-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Broadwell</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core2-E6850-guest.xml b/tests/cputestdata/x86_64-cpuid-Core2-E6850-guest.xml index dfcbe24da..2392de6ce 100644 --- a/tests/cputestdata/x86_64-cpuid-Core2-E6850-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Core2-E6850-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Conroe</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core2-E6850-json.xml b/tests/cputestdata/x86_64-cpuid-Core2-E6850-json.xml index 8950119a1..e4117c293 100644 --- a/tests/cputestdata/x86_64-cpuid-Core2-E6850-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Core2-E6850-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Conroe</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Core2-Q9500-guest.xml b/tests/cputestdata/x86_64-cpuid-Core2-Q9500-guest.xml index 37feefa9c..aa151bc54 100644 --- a/tests/cputestdata/x86_64-cpuid-Core2-Q9500-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Core2-Q9500-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Penryn</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-FX-8150-guest.xml b/tests/cputestdata/x86_64-cpuid-FX-8150-guest.xml index 9858ee4e2..6bd032bbc 100644 --- a/tests/cputestdata/x86_64-cpuid-FX-8150-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-FX-8150-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Opteron_G4</model> <vendor>AMD</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Opteron-1352-guest.xml b/tests/cputestdata/x86_64-cpuid-Opteron-1352-guest.xml index 828a14271..652f1e433 100644 --- a/tests/cputestdata/x86_64-cpuid-Opteron-1352-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Opteron-1352-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Opteron_G3</model> <vendor>AMD</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Opteron-2350-guest.xml b/tests/cputestdata/x86_64-cpuid-Opteron-2350-guest.xml index 828a14271..652f1e433 100644 --- a/tests/cputestdata/x86_64-cpuid-Opteron-2350-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Opteron-2350-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Opteron_G3</model> <vendor>AMD</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Opteron-2350-json.xml b/tests/cputestdata/x86_64-cpuid-Opteron-2350-json.xml index 302d6562c..741757aeb 100644 --- a/tests/cputestdata/x86_64-cpuid-Opteron-2350-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Opteron-2350-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Opteron_G3</model> <vendor>AMD</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Opteron-6234-guest.xml b/tests/cputestdata/x86_64-cpuid-Opteron-6234-guest.xml index 9858ee4e2..6bd032bbc 100644 --- a/tests/cputestdata/x86_64-cpuid-Opteron-6234-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Opteron-6234-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Opteron_G4</model> <vendor>AMD</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Opteron-6234-json.xml b/tests/cputestdata/x86_64-cpuid-Opteron-6234-json.xml index cc8918661..2ad3c98a5 100644 --- a/tests/cputestdata/x86_64-cpuid-Opteron-6234-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Opteron-6234-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Opteron_G4</model> <vendor>AMD</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Opteron-6282-guest.xml b/tests/cputestdata/x86_64-cpuid-Opteron-6282-guest.xml index 9858ee4e2..6bd032bbc 100644 --- a/tests/cputestdata/x86_64-cpuid-Opteron-6282-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Opteron-6282-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Opteron_G4</model> <vendor>AMD</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Pentium-P6100-guest.xml b/tests/cputestdata/x86_64-cpuid-Pentium-P6100-guest.xml index f893f9f23..db5e0ae6a 100644 --- a/tests/cputestdata/x86_64-cpuid-Pentium-P6100-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Pentium-P6100-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>core2duo</model> <vendor>Intel</vendor> <feature policy='require' name='ds'/> diff --git a/tests/cputestdata/x86_64-cpuid-Phenom-B95-guest.xml b/tests/cputestdata/x86_64-cpuid-Phenom-B95-guest.xml index 60ba9c1eb..d7a06108b 100644 --- a/tests/cputestdata/x86_64-cpuid-Phenom-B95-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Phenom-B95-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Opteron_G3</model> <vendor>AMD</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Phenom-B95-json.xml b/tests/cputestdata/x86_64-cpuid-Phenom-B95-json.xml index d4605263b..7ce56ac8e 100644 --- a/tests/cputestdata/x86_64-cpuid-Phenom-B95-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Phenom-B95-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Opteron_G3</model> <vendor>AMD</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-5110-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-5110-guest.xml index 28d112b34..d1b442d33 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-5110-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-5110-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Conroe</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-guest.xml index 0ab5a7a7b..c3561d597 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Skylake-Client</model> <vendor>Intel</vendor> <feature policy='require' name='ds'/> diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-json.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-json.xml index e0e060691..7af75509e 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-E3-1245-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Skylake-Client</model> <vendor>Intel</vendor> <feature policy='require' name='ss'/> diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-guest.xml index b02d963c1..980af0789 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Haswell-noTSX</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-json.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-json.xml index ec5f56205..78b8be111 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2630-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Haswell-noTSX</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-guest.xml index b02d963c1..980af0789 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Haswell-noTSX</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-json.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-json.xml index 6e4aff07a..2227ed003 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-E5-2650-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Haswell-noTSX</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-guest.xml index 81bf8c8c2..dbf8580a0 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>SandyBridge</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-json.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-json.xml index cb69ff56f..d94a330f3 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-E7-4820-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>SandyBridge</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-E7-8890-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-E7-8890-guest.xml index c62e36a3a..16d333aa2 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-E7-8890-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-E7-8890-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Haswell</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-W3520-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-W3520-guest.xml index 4037fa60c..9c975c679 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-W3520-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-W3520-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Nehalem</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-W3520-json.xml b/tests/cputestdata/x86_64-cpuid-Xeon-W3520-json.xml index 348bef829..038c98e1d 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-W3520-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-W3520-json.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Nehalem</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-X5460-guest.xml b/tests/cputestdata/x86_64-cpuid-Xeon-X5460-guest.xml index 9e21934b4..a97efc565 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-X5460-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-X5460-guest.xml @@ -1,5 +1,4 @@ <cpu mode='custom' match='exact'> - <arch>x86_64</arch> <model fallback='forbid'>Penryn</model> <vendor>Intel</vendor> <feature policy='require' name='vme'/> -- 2.12.0

cpuNodeData has always been followed by cpuDecode as no hypervisor driver is really interested in raw CPUID data for a host CPU. Let's create a new CPU driver API which returns virCPUDefPtr directly. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/bhyve/bhyve_capabilities.c | 34 ++++--------------------- src/cpu/cpu.c | 58 ++++++++++++++++++++++++++++++++++-------- src/cpu/cpu.h | 11 ++++---- src/cpu/cpu_arm.c | 1 - src/cpu/cpu_ppc64.c | 28 ++++++++++---------- src/cpu/cpu_s390.c | 1 - src/cpu/cpu_x86.c | 27 +++++++++----------- src/libvirt_private.syms | 2 +- src/qemu/qemu_capabilities.c | 32 +++-------------------- src/vmware/vmware_conf.c | 19 +++----------- src/vz/vz_driver.c | 21 ++------------- 11 files changed, 95 insertions(+), 139 deletions(-) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index 52d6ca782..c2c9303d7 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -40,41 +40,17 @@ VIR_LOG_INIT("bhyve.bhyve_capabilities"); static int virBhyveCapsInitCPU(virCapsPtr caps, - virArch arch) + virArch arch) { - virCPUDefPtr cpu = NULL; - virCPUDataPtr data = NULL; virNodeInfo nodeinfo; - int ret = -1; - - if (VIR_ALLOC(cpu) < 0) - goto error; - - cpu->arch = arch; if (nodeGetInfo(&nodeinfo)) - goto error; + return -1; - cpu->type = VIR_CPU_TYPE_HOST; - cpu->sockets = nodeinfo.sockets; - cpu->cores = nodeinfo.cores; - cpu->threads = nodeinfo.threads; - caps->host.cpu = cpu; + if (!(caps->host.cpu = virCPUGetHost(arch, &nodeinfo))) + return -1; - if (!(data = cpuNodeData(arch)) || - cpuDecode(cpu, data, NULL, 0, NULL) < 0) - goto cleanup; - - ret = 0; - - cleanup: - virCPUDataFree(data); - - return ret; - - error: - virCPUDefFree(cpu); - goto cleanup; + return 0; } virCapsPtr diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 051a58040..c1666ed3b 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -357,30 +357,66 @@ virCPUDataFree(virCPUDataPtr data) /** - * cpuNodeData: + * virCPUGetHost: * * @arch: CPU architecture + * @nodeInfo: simplified CPU topology (optional) * - * Returns CPU data for host CPU or NULL on error. + * Create CPU definition describing the host's CPU. If @nodeInfo is not NULL, + * the CPU definition will have topology (sockets, cores, threads) filled in + * according to the content of @nodeInfo. The function fails only if @nodeInfo + * was not passed in and the assigned CPU driver was not able to detect the + * host CPU model. In other words, a CPU definition containing just the + * topology is a successful result even if detecting the host CPU model fails. + * + * Returns host CPU definition or NULL on error. */ -virCPUDataPtr -cpuNodeData(virArch arch) +virCPUDefPtr +virCPUGetHost(virArch arch, + virNodeInfoPtr nodeInfo) { struct cpuArchDriver *driver; + virCPUDefPtr cpu = NULL; - VIR_DEBUG("arch=%s", virArchToString(arch)); + VIR_DEBUG("arch=%s, nodeInfo=%p", + virArchToString(arch), nodeInfo); - if ((driver = cpuGetSubDriver(arch)) == NULL) + if (!(driver = cpuGetSubDriver(arch))) return NULL; - if (driver->nodeData == NULL) { - virReportError(VIR_ERR_NO_SUPPORT, - _("cannot get node CPU data for %s architecture"), - virArchToString(arch)); + if (VIR_ALLOC(cpu) < 0) return NULL; + + cpu->arch = arch; + cpu->type = VIR_CPU_TYPE_HOST; + + if (nodeInfo) { + cpu->sockets = nodeInfo->sockets; + cpu->cores = nodeInfo->cores; + cpu->threads = nodeInfo->threads; } - return driver->nodeData(arch); + /* Try to get the host CPU model, but don't really fail if nodeInfo is + * filled in. + */ + if (driver->getHost) { + if (driver->getHost(cpu) < 0 && !nodeInfo) + goto error; + } else if (nodeInfo) { + VIR_DEBUG("cannot detect host CPU model for %s architecture", + virArchToString(arch)); + } else { + virReportError(VIR_ERR_NO_SUPPORT, + _("cannot detect host CPU model for %s architecture"), + virArchToString(arch)); + goto error; + } + + return cpu; + + error: + virCPUDefFree(cpu); + return NULL; } diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 0324284b9..cbbb45223 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -70,8 +70,8 @@ typedef int typedef void (*cpuArchDataFree) (virCPUDataPtr data); -typedef virCPUDataPtr -(*cpuArchNodeData) (virArch arch); +typedef int +(*virCPUArchGetHost)(virCPUDefPtr cpu); typedef virCPUDefPtr (*cpuArchBaseline) (virCPUDefPtr *cpus, @@ -117,7 +117,7 @@ struct cpuArchDriver { cpuArchDecode decode; cpuArchEncode encode; cpuArchDataFree dataFree; - cpuArchNodeData nodeData; + virCPUArchGetHost getHost; cpuArchBaseline baseline; virCPUArchUpdate update; virCPUArchCheckFeature checkFeature; @@ -168,8 +168,9 @@ virCPUDataNew(virArch arch); void virCPUDataFree(virCPUDataPtr data); -virCPUDataPtr -cpuNodeData (virArch arch); +virCPUDefPtr +virCPUGetHost(virArch arch, + virNodeInfoPtr nodeInfo); char * cpuBaselineXML(const char **xmlCPUs, diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c index 3a0ee2b14..a1aba2554 100644 --- a/src/cpu/cpu_arm.c +++ b/src/cpu/cpu_arm.c @@ -111,7 +111,6 @@ struct cpuArchDriver cpuDriverArm = { .compare = virCPUarmCompare, .decode = NULL, .encode = NULL, - .nodeData = NULL, .baseline = armBaseline, .update = virCPUarmUpdate, }; diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c index a7c8545db..bb715546b 100644 --- a/src/cpu/cpu_ppc64.c +++ b/src/cpu/cpu_ppc64.c @@ -714,19 +714,21 @@ virCPUppc64DataFree(virCPUDataPtr data) VIR_FREE(data); } -static virCPUDataPtr -ppc64DriverNodeData(virArch arch) + +static int +virCPUppc64GetHost(virCPUDefPtr cpu) { - virCPUDataPtr nodeData; + virCPUDataPtr cpuData = NULL; virCPUppc64Data *data; + int ret = -1; - if (VIR_ALLOC(nodeData) < 0) - goto error; + if (!(cpuData = virCPUDataNew(archs[0]))) + goto cleanup; - data = &nodeData->data.ppc64; + data = &cpuData->data.ppc64; if (VIR_ALLOC_N(data->pvr, 1) < 0) - goto error; + goto cleanup; data->len = 1; @@ -736,13 +738,11 @@ ppc64DriverNodeData(virArch arch) #endif data->pvr[0].mask = 0xfffffffful; - nodeData->arch = arch; + ret = ppc64DriverDecode(cpu, cpuData, NULL, 0, NULL, 0); - return nodeData; - - error: - virCPUppc64DataFree(nodeData); - return NULL; + cleanup: + virCPUppc64DataFree(cpuData); + return ret; } @@ -902,7 +902,7 @@ struct cpuArchDriver cpuDriverPPC64 = { .decode = ppc64DriverDecode, .encode = NULL, .dataFree = virCPUppc64DataFree, - .nodeData = ppc64DriverNodeData, + .getHost = virCPUppc64GetHost, .baseline = ppc64DriverBaseline, .update = virCPUppc64Update, .getModels = virCPUppc64DriverGetModels, diff --git a/src/cpu/cpu_s390.c b/src/cpu/cpu_s390.c index 9503e8e2b..c08a24a53 100644 --- a/src/cpu/cpu_s390.c +++ b/src/cpu/cpu_s390.c @@ -109,7 +109,6 @@ struct cpuArchDriver cpuDriverS390 = { .compare = virCPUs390Compare, .decode = NULL, .encode = NULL, - .nodeData = NULL, .baseline = NULL, .update = virCPUs390Update, }; diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index bcf50cb9e..bddb169ba 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2437,25 +2437,24 @@ cpuidSet(uint32_t base, virCPUDataPtr data) } -static virCPUDataPtr -x86NodeData(virArch arch) +static int +virCPUx86GetHost(virCPUDefPtr cpu) { virCPUDataPtr cpuData = NULL; + int ret = -1; - if (!(cpuData = virCPUDataNew(arch))) - goto error; + if (!(cpuData = virCPUDataNew(archs[0]))) + goto cleanup; - if (cpuidSet(CPUX86_BASIC, cpuData) < 0) - goto error; + if (cpuidSet(CPUX86_BASIC, cpuData) < 0 || + cpuidSet(CPUX86_EXTENDED, cpuData) < 0) + goto cleanup; - if (cpuidSet(CPUX86_EXTENDED, cpuData) < 0) - goto error; + ret = x86DecodeCPUData(cpu, cpuData, NULL, 0, NULL, 0); - return cpuData; - - error: + cleanup: virCPUx86DataFree(cpuData); - return NULL; + return ret; } #endif @@ -2849,9 +2848,7 @@ struct cpuArchDriver cpuDriverX86 = { .encode = x86Encode, .dataFree = virCPUx86DataFree, #if defined(__i386__) || defined(__x86_64__) - .nodeData = x86NodeData, -#else - .nodeData = NULL, + .getHost = virCPUx86GetHost, #endif .baseline = x86Baseline, .update = virCPUx86Update, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6c89d44e2..4efea0098 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -996,7 +996,6 @@ cpuBaseline; cpuBaselineXML; cpuDecode; cpuEncode; -cpuNodeData; virCPUCheckFeature; virCPUCompare; virCPUCompareXML; @@ -1006,6 +1005,7 @@ virCPUDataFormat; virCPUDataFree; virCPUDataNew; virCPUDataParse; +virCPUGetHost; virCPUGetModels; virCPUTranslate; virCPUUpdate; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5a3b4ac50..b0a4861c3 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1065,39 +1065,15 @@ static int virQEMUCapsInitCPU(virCapsPtr caps, virArch arch) { - virCPUDefPtr cpu = NULL; - virCPUDataPtr data = NULL; virNodeInfo nodeinfo; - int ret = -1; - - if (VIR_ALLOC(cpu) < 0) - goto error; - - cpu->arch = arch; if (nodeGetInfo(&nodeinfo)) - goto error; + return -1; - cpu->type = VIR_CPU_TYPE_HOST; - cpu->sockets = nodeinfo.sockets; - cpu->cores = nodeinfo.cores; - cpu->threads = nodeinfo.threads; - caps->host.cpu = cpu; + if (!(caps->host.cpu = virCPUGetHost(arch, &nodeinfo))) + return -1; - if (!(data = cpuNodeData(arch)) - || cpuDecode(cpu, data, NULL, 0, NULL) < 0) - goto cleanup; - - ret = 0; - - cleanup: - virCPUDataFree(data); - - return ret; - - error: - virCPUDefFree(cpu); - goto cleanup; + return 0; } diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 5b1b5f5fd..d1444e462 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -62,7 +62,6 @@ vmwareCapsInit(void) virCapsPtr caps = NULL; virCapsGuestPtr guest = NULL; virCPUDefPtr cpu = NULL; - virCPUDataPtr data = NULL; if ((caps = virCapabilitiesNew(virArchFromHost(), false, false)) == NULL) @@ -83,26 +82,18 @@ vmwareCapsInit(void) NULL, NULL, 0, NULL) == NULL) goto error; - if (VIR_ALLOC(cpu) < 0) + if (!(cpu = virCPUGetHost(caps->host.arch, NULL))) goto error; - cpu->arch = caps->host.arch; - cpu->type = VIR_CPU_TYPE_HOST; - - if (!(data = cpuNodeData(cpu->arch)) - || cpuDecode(cpu, data, NULL, 0, NULL) < 0) { - goto error; - } - /* x86_64 guests are supported if * - Host arch is x86_64 * Or * - Host CPU is x86_64 with virtualization extensions */ if (caps->host.arch == VIR_ARCH_X86_64 || - (virCPUDataCheckFeature(data, "lm") && - (virCPUDataCheckFeature(data, "vmx") || - virCPUDataCheckFeature(data, "svm")))) { + (virCPUCheckFeature(cpu->arch, cpu, "lm") && + (virCPUCheckFeature(cpu->arch, cpu, "vmx") || + virCPUCheckFeature(cpu->arch, cpu, "svm")))) { if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, @@ -118,8 +109,6 @@ vmwareCapsInit(void) cleanup: virCPUDefFree(cpu); - virCPUDataFree(data); - return caps; error: diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 1ca9fd726..f97a2045b 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -99,8 +99,6 @@ static virCapsPtr vzBuildCapabilities(void) { virCapsPtr caps = NULL; - virCPUDefPtr cpu = NULL; - virCPUDataPtr data = NULL; virNodeInfo nodeinfo; virDomainOSType ostypes[] = { VIR_DOMAIN_OSTYPE_HVM, @@ -131,32 +129,17 @@ vzBuildCapabilities(void) if (nodeGetInfo(&nodeinfo)) goto error; - if (VIR_ALLOC(cpu) < 0) + if (!(caps->host.cpu = virCPUGetHost(caps->host.arch, &nodeinfo))) goto error; - cpu->arch = caps->host.arch; - cpu->type = VIR_CPU_TYPE_HOST; - cpu->sockets = nodeinfo.sockets; - cpu->cores = nodeinfo.cores; - cpu->threads = nodeinfo.threads; - - caps->host.cpu = cpu; - if (virCapabilitiesAddHostMigrateTransport(caps, "vzmigr") < 0) goto error; - if (!(data = cpuNodeData(cpu->arch)) - || cpuDecode(cpu, data, NULL, 0, NULL) < 0) { - goto cleanup; - } - - cleanup: - virCPUDataFree(data); return caps; error: virObjectUnref(caps); - goto cleanup; + return NULL; } static void vzDriverDispose(void * obj) -- 2.12.0

The parameter can be used to request either VIR_CPU_TYPE_HOST (which has been assumed so far) or VIR_CPU_TYPE_GUEST definition. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/bhyve/bhyve_capabilities.c | 2 +- src/cpu/cpu.c | 41 ++++++++++++++++++++++++++++++++++++----- src/cpu/cpu.h | 1 + src/qemu/qemu_capabilities.c | 2 +- src/vmware/vmware_conf.c | 2 +- src/vz/vz_driver.c | 3 ++- 6 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index c2c9303d7..33e670c5c 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -47,7 +47,7 @@ virBhyveCapsInitCPU(virCapsPtr caps, if (nodeGetInfo(&nodeinfo)) return -1; - if (!(caps->host.cpu = virCPUGetHost(arch, &nodeinfo))) + if (!(caps->host.cpu = virCPUGetHost(arch, VIR_CPU_TYPE_HOST, &nodeinfo))) return -1; return 0; diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index c1666ed3b..110bb240c 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -360,9 +360,18 @@ virCPUDataFree(virCPUDataPtr data) * virCPUGetHost: * * @arch: CPU architecture + * @type: requested type of the CPU * @nodeInfo: simplified CPU topology (optional) * - * Create CPU definition describing the host's CPU. If @nodeInfo is not NULL, + * Create CPU definition describing the host's CPU. + * + * The @type (either VIR_CPU_TYPE_HOST or VIR_CPU_TYPE_GUEST) specifies what + * type of CPU definition should be created. Specifically, VIR_CPU_TYPE_HOST + * CPUs may contain only features without any policy attribute. Requesting + * VIR_CPU_TYPE_GUEST provides better results because the CPU is allowed to + * contain disabled features. + * + * If @nodeInfo is not NULL (which is only allowed for VIR_CPU_TYPE_HOST CPUs), * the CPU definition will have topology (sockets, cores, threads) filled in * according to the content of @nodeInfo. The function fails only if @nodeInfo * was not passed in and the assigned CPU driver was not able to detect the @@ -373,13 +382,14 @@ virCPUDataFree(virCPUDataPtr data) */ virCPUDefPtr virCPUGetHost(virArch arch, + virCPUType type, virNodeInfoPtr nodeInfo) { struct cpuArchDriver *driver; virCPUDefPtr cpu = NULL; - VIR_DEBUG("arch=%s, nodeInfo=%p", - virArchToString(arch), nodeInfo); + VIR_DEBUG("arch=%s, type=%s, nodeInfo=%p", + virArchToString(arch), virCPUTypeToString(type), nodeInfo); if (!(driver = cpuGetSubDriver(arch))) return NULL; @@ -387,8 +397,29 @@ virCPUGetHost(virArch arch, if (VIR_ALLOC(cpu) < 0) return NULL; - cpu->arch = arch; - cpu->type = VIR_CPU_TYPE_HOST; + switch (type) { + case VIR_CPU_TYPE_HOST: + cpu->arch = arch; + cpu->type = type; + break; + + case VIR_CPU_TYPE_GUEST: + if (nodeInfo) { + virReportError(VIR_ERR_INVALID_ARG, + _("cannot set topology for CPU type '%s'"), + virCPUTypeToString(type)); + goto error; + } + cpu->type = type; + break; + + case VIR_CPU_TYPE_AUTO: + case VIR_CPU_TYPE_LAST: + virReportError(VIR_ERR_INVALID_ARG, + _("unsupported CPU type: %s"), + virCPUTypeToString(type)); + goto error; + } if (nodeInfo) { cpu->sockets = nodeInfo->sockets; diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index cbbb45223..e5eca08c3 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -170,6 +170,7 @@ virCPUDataFree(virCPUDataPtr data); virCPUDefPtr virCPUGetHost(virArch arch, + virCPUType type, virNodeInfoPtr nodeInfo); char * diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b0a4861c3..b39014224 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1070,7 +1070,7 @@ virQEMUCapsInitCPU(virCapsPtr caps, if (nodeGetInfo(&nodeinfo)) return -1; - if (!(caps->host.cpu = virCPUGetHost(arch, &nodeinfo))) + if (!(caps->host.cpu = virCPUGetHost(arch, VIR_CPU_TYPE_HOST, &nodeinfo))) return -1; return 0; diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index d1444e462..cb6d60724 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -82,7 +82,7 @@ vmwareCapsInit(void) NULL, NULL, 0, NULL) == NULL) goto error; - if (!(cpu = virCPUGetHost(caps->host.arch, NULL))) + if (!(cpu = virCPUGetHost(caps->host.arch, VIR_CPU_TYPE_HOST, NULL))) goto error; /* x86_64 guests are supported if diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index f97a2045b..67ec2727b 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -129,7 +129,8 @@ vzBuildCapabilities(void) if (nodeGetInfo(&nodeinfo)) goto error; - if (!(caps->host.cpu = virCPUGetHost(caps->host.arch, &nodeinfo))) + if (!(caps->host.cpu = virCPUGetHost(caps->host.arch, VIR_CPU_TYPE_HOST, + &nodeinfo))) goto error; if (virCapabilitiesAddHostMigrateTransport(caps, "vzmigr") < 0) -- 2.12.0

When creating host CPU definition usable with a given emulator, the CPU should not be defined using an unsupported CPU model. The new @models and @nmodels parameters can be used to limit CPU models which can be used in the result. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/bhyve/bhyve_capabilities.c | 3 ++- src/cpu/cpu.c | 19 +++++++++++++++---- src/cpu/cpu.h | 8 ++++++-- src/cpu/cpu_ppc64.c | 6 ++++-- src/cpu/cpu_x86.c | 6 ++++-- src/qemu/qemu_capabilities.c | 3 ++- src/vmware/vmware_conf.c | 3 ++- src/vz/vz_driver.c | 2 +- 8 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index 33e670c5c..60db0b791 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -47,7 +47,8 @@ virBhyveCapsInitCPU(virCapsPtr caps, if (nodeGetInfo(&nodeinfo)) return -1; - if (!(caps->host.cpu = virCPUGetHost(arch, VIR_CPU_TYPE_HOST, &nodeinfo))) + if (!(caps->host.cpu = virCPUGetHost(arch, VIR_CPU_TYPE_HOST, + &nodeinfo, NULL, 0))) return -1; return 0; diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 110bb240c..5b1940b47 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -362,6 +362,8 @@ virCPUDataFree(virCPUDataPtr data) * @arch: CPU architecture * @type: requested type of the CPU * @nodeInfo: simplified CPU topology (optional) + * @models: list of CPU models that can be considered for host CPU + * @nmodels: number of CPU models in @models * * Create CPU definition describing the host's CPU. * @@ -378,18 +380,26 @@ virCPUDataFree(virCPUDataPtr data) * host CPU model. In other words, a CPU definition containing just the * topology is a successful result even if detecting the host CPU model fails. * + * It possible to limit the CPU model which may appear in the created CPU + * definition by passing non-NULL @models list. This is useful when requesting + * a CPU model usable on a specific hypervisor. If @models is NULL, any CPU + * model known to libvirt may appear in the result. + * * Returns host CPU definition or NULL on error. */ virCPUDefPtr virCPUGetHost(virArch arch, virCPUType type, - virNodeInfoPtr nodeInfo) + virNodeInfoPtr nodeInfo, + const char **models, + unsigned int nmodels) { struct cpuArchDriver *driver; virCPUDefPtr cpu = NULL; - VIR_DEBUG("arch=%s, type=%s, nodeInfo=%p", - virArchToString(arch), virCPUTypeToString(type), nodeInfo); + VIR_DEBUG("arch=%s, type=%s, nodeInfo=%p, models=%p, nmodels=%u", + virArchToString(arch), virCPUTypeToString(type), nodeInfo, + models, nmodels); if (!(driver = cpuGetSubDriver(arch))) return NULL; @@ -431,7 +441,8 @@ virCPUGetHost(virArch arch, * filled in. */ if (driver->getHost) { - if (driver->getHost(cpu) < 0 && !nodeInfo) + if (driver->getHost(cpu, models, nmodels) < 0 && + !nodeInfo) goto error; } else if (nodeInfo) { VIR_DEBUG("cannot detect host CPU model for %s architecture", diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index e5eca08c3..c329eb134 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -71,7 +71,9 @@ typedef void (*cpuArchDataFree) (virCPUDataPtr data); typedef int -(*virCPUArchGetHost)(virCPUDefPtr cpu); +(*virCPUArchGetHost)(virCPUDefPtr cpu, + const char **models, + unsigned int nmodels); typedef virCPUDefPtr (*cpuArchBaseline) (virCPUDefPtr *cpus, @@ -171,7 +173,9 @@ virCPUDataFree(virCPUDataPtr data); virCPUDefPtr virCPUGetHost(virArch arch, virCPUType type, - virNodeInfoPtr nodeInfo); + virNodeInfoPtr nodeInfo, + const char **models, + unsigned int nmodels); char * cpuBaselineXML(const char **xmlCPUs, diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c index bb715546b..6e16ffd13 100644 --- a/src/cpu/cpu_ppc64.c +++ b/src/cpu/cpu_ppc64.c @@ -716,7 +716,9 @@ virCPUppc64DataFree(virCPUDataPtr data) static int -virCPUppc64GetHost(virCPUDefPtr cpu) +virCPUppc64GetHost(virCPUDefPtr cpu, + const char **models, + unsigned int nmodels) { virCPUDataPtr cpuData = NULL; virCPUppc64Data *data; @@ -738,7 +740,7 @@ virCPUppc64GetHost(virCPUDefPtr cpu) #endif data->pvr[0].mask = 0xfffffffful; - ret = ppc64DriverDecode(cpu, cpuData, NULL, 0, NULL, 0); + ret = ppc64DriverDecode(cpu, cpuData, models, nmodels, NULL, 0); cleanup: virCPUppc64DataFree(cpuData); diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index bddb169ba..6719acee2 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2438,7 +2438,9 @@ cpuidSet(uint32_t base, virCPUDataPtr data) static int -virCPUx86GetHost(virCPUDefPtr cpu) +virCPUx86GetHost(virCPUDefPtr cpu, + const char **models, + unsigned int nmodels) { virCPUDataPtr cpuData = NULL; int ret = -1; @@ -2450,7 +2452,7 @@ virCPUx86GetHost(virCPUDefPtr cpu) cpuidSet(CPUX86_EXTENDED, cpuData) < 0) goto cleanup; - ret = x86DecodeCPUData(cpu, cpuData, NULL, 0, NULL, 0); + ret = x86DecodeCPUData(cpu, cpuData, models, nmodels, NULL, 0); cleanup: virCPUx86DataFree(cpuData); diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b39014224..319600c30 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1070,7 +1070,8 @@ virQEMUCapsInitCPU(virCapsPtr caps, if (nodeGetInfo(&nodeinfo)) return -1; - if (!(caps->host.cpu = virCPUGetHost(arch, VIR_CPU_TYPE_HOST, &nodeinfo))) + if (!(caps->host.cpu = virCPUGetHost(arch, VIR_CPU_TYPE_HOST, + &nodeinfo, NULL, 0))) return -1; return 0; diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index cb6d60724..659c4737a 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -82,7 +82,8 @@ vmwareCapsInit(void) NULL, NULL, 0, NULL) == NULL) goto error; - if (!(cpu = virCPUGetHost(caps->host.arch, VIR_CPU_TYPE_HOST, NULL))) + if (!(cpu = virCPUGetHost(caps->host.arch, VIR_CPU_TYPE_HOST, + NULL, NULL, 0))) goto error; /* x86_64 guests are supported if diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 67ec2727b..b5d2964f3 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -130,7 +130,7 @@ vzBuildCapabilities(void) goto error; if (!(caps->host.cpu = virCPUGetHost(caps->host.arch, VIR_CPU_TYPE_HOST, - &nodeinfo))) + &nodeinfo, NULL, 0))) goto error; if (virCapabilitiesAddHostMigrateTransport(caps, "vzmigr") < 0) -- 2.12.0

The function is now called virQEMUCapsProbeHostCPU. Both the refactoring and the change of the name is done for consistency with a new function which will be introduced in the following commit. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/qemu/qemu_capabilities.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 319600c30..08c66b088 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1061,20 +1061,16 @@ virQEMUCapsInitGuestFromBinary(virCapsPtr caps, } -static int -virQEMUCapsInitCPU(virCapsPtr caps, - virArch arch) +static virCPUDefPtr +virQEMUCapsProbeHostCPU(virCapsPtr caps) { virNodeInfo nodeinfo; if (nodeGetInfo(&nodeinfo)) - return -1; + return NULL; - if (!(caps->host.cpu = virCPUGetHost(arch, VIR_CPU_TYPE_HOST, - &nodeinfo, NULL, 0))) - return -1; - - return 0; + return virCPUGetHost(caps->host.arch, VIR_CPU_TYPE_HOST, + &nodeinfo, NULL, 0); } @@ -1120,7 +1116,7 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache) VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities"); } - if (virQEMUCapsInitCPU(caps, hostarch) < 0) + if (!(caps->host.cpu = virQEMUCapsProbeHostCPU(caps))) VIR_WARN("Failed to get host CPU"); /* Add the power management features of the host */ -- 2.12.0

One of the main reasons for introducing host-model CPU definition in a domain capabilities XML was the inability to express disabled features in a host capabilities XML. That is, when a host CPU is, e.g., Haswell without x2apic support, host capabilities XML will have to report it as Westmere + a bunch of additional features., but we really want to use Haswell - x2apic when creating a host-model CPU. Unfortunately, I somehow forgot to do the last step and the code would just copy the CPU definition found in the host capabilities XML. This changed recently for new QEMU versions which allow us to query host CPU, but any slightly older QEMU will not benefit from any change I did. This patch makes sure the right CPU model is filled in the domain capabilities even with old QEMU. The issue was reported in https://bugzilla.redhat.com/show_bug.cgi?id=1426456 Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/qemu/qemu_capabilities.c | 32 ++++++++++++++++++++++++++++---- src/qemu/qemu_capspriv.h | 5 +++++ tests/Makefile.am | 11 +++++++++-- tests/domaincapstest.c | 6 ++++++ tests/qemucpumock.c | 35 +++++++++++++++++++++++++++++++++++ tests/qemuxml2argvtest.c | 6 ++++-- 6 files changed, 87 insertions(+), 8 deletions(-) create mode 100644 tests/qemucpumock.c diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 08c66b088..70f9ed777 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1074,6 +1074,26 @@ virQEMUCapsProbeHostCPU(virCapsPtr caps) } +virCPUDefPtr +virQEMUCapsProbeHostCPUForEmulator(virCapsPtr caps, + virQEMUCapsPtr qemuCaps, + virDomainVirtType type) +{ + size_t nmodels; + char **models; + virCPUDefPtr cpu; + + if (virQEMUCapsGetCPUDefinitions(qemuCaps, type, &models, &nmodels) < 0) + return NULL; + + cpu = virCPUGetHost(caps->host.arch, VIR_CPU_TYPE_GUEST, NULL, + (const char **) models, nmodels); + + virStringListFreeCount(models, nmodels); + return cpu; +} + + static int virQEMUCapsInitPages(virCapsPtr caps) { @@ -3207,6 +3227,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps, virDomainVirtType type) { virCPUDefPtr cpu = NULL; + virCPUDefPtr hostCPU = NULL; int rc; if (!caps || !virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch)) @@ -3223,11 +3244,11 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps, if ((rc = virQEMUCapsInitCPUModel(qemuCaps, type, cpu)) < 0) { goto error; } else if (rc == 1) { - VIR_DEBUG("No host CPU model info from QEMU; using host capabilities"); - if (!caps->host.cpu || !caps->host.cpu->model) - goto error; + VIR_DEBUG("No host CPU model info from QEMU; probing host CPU directly"); - if (virCPUDefCopyModelFilter(cpu, caps->host.cpu, true, + hostCPU = virQEMUCapsProbeHostCPUForEmulator(caps, qemuCaps, type); + if (!hostCPU || + virCPUDefCopyModelFilter(cpu, hostCPU, true, virQEMUCapsCPUFilterFeatures, qemuCaps) < 0) goto error; @@ -3238,11 +3259,14 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps, else qemuCaps->tcgCPUModel = cpu; + cleanup: + virCPUDefFree(hostCPU); return; error: virCPUDefFree(cpu); virResetLastError(); + goto cleanup; } diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h index e0544f273..ee29b8bba 100644 --- a/src/qemu/qemu_capspriv.h +++ b/src/qemu/qemu_capspriv.h @@ -87,4 +87,9 @@ void virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps, virDomainVirtType type, qemuMonitorCPUModelInfoPtr modelInfo); + +virCPUDefPtr +virQEMUCapsProbeHostCPUForEmulator(virCapsPtr caps, + virQEMUCapsPtr qemuCaps, + virDomainVirtType type); #endif diff --git a/tests/Makefile.am b/tests/Makefile.am index 35e82abf5..af69a3a84 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -284,6 +284,7 @@ test_libraries += libqemumonitortestutils.la \ qemuxml2xmlmock.la \ qemucaps2xmlmock.la \ qemucapsprobemock.la \ + qemucpumock.la \ $(NULL) endif WITH_QEMU @@ -549,10 +550,16 @@ libqemutestdriver_la_SOURCES = libqemutestdriver_la_LDFLAGS = $(QEMULIB_LDFLAGS) libqemutestdriver_la_LIBADD = $(qemu_LDADDS) +qemucpumock_la_SOURCES = \ + qemucpumock.c +qemucpumock_la_CFLAGS = $(AM_CFLAGS) +qemucpumock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS) +qemucpumock_la_LIBADD = $(MOCKLIBS_LIBS) + qemuxml2argvtest_SOURCES = \ qemuxml2argvtest.c testutilsqemu.c testutilsqemu.h \ testutils.c testutils.h -qemuxml2argvtest_LDADD = $(qemu_LDADDS) $(LDADDS) $(LIBXML_LIBS) +qemuxml2argvtest_LDADD = libqemutestdriver.la $(LDADDS) $(LIBXML_LIBS) qemuxml2argvmock_la_SOURCES = \ qemuxml2argvmock.c @@ -949,7 +956,7 @@ domaincapstest_LDADD = $(LDADDS) if WITH_QEMU domaincapstest_SOURCES += testutilsqemu.c testutilsqemu.h -domaincapstest_LDADD += $(qemu_LDADDS) $(GNULIB_LIBS) +domaincapstest_LDADD += libqemutestdriver.la $(GNULIB_LIBS) endif WITH_QEMU if WITH_LIBXL diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 9b64f2c18..a4bc8d6d0 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -491,4 +491,10 @@ mymain(void) return ret; } +#if WITH_QEMU +VIRT_TEST_MAIN_PRELOAD(mymain, + abs_builddir "/.libs/domaincapsmock.so", + abs_builddir "/.libs/qemucpumock.so") +#else VIRT_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/domaincapsmock.so") +#endif diff --git a/tests/qemucpumock.c b/tests/qemucpumock.c new file mode 100644 index 000000000..2c1d24dd4 --- /dev/null +++ b/tests/qemucpumock.c @@ -0,0 +1,35 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + */ + +#include <config.h> + +#include "internal.h" +#include "qemu/qemu_capabilities.h" +#define __QEMU_CAPSRIV_H_ALLOW__ +#include "qemu/qemu_capspriv.h" +#undef __QEMU_CAPSRIV_H_ALLOW__ + + +virCPUDefPtr +virQEMUCapsProbeHostCPUForEmulator(virCapsPtr caps, + virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED, + virDomainVirtType type ATTRIBUTE_UNUSED) +{ + if (!caps || !caps->host.cpu || !caps->host.cpu->model) + return NULL; + + return virCPUDefCopy(caps->host.cpu); +} diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d2d267fce..018b176c4 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2476,8 +2476,10 @@ mymain(void) return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -VIRT_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/qemuxml2argvmock.so", - abs_builddir "/.libs/virrandommock.so") +VIRT_TEST_MAIN_PRELOAD(mymain, + abs_builddir "/.libs/qemuxml2argvmock.so", + abs_builddir "/.libs/virrandommock.so", + abs_builddir "/.libs/qemucpumock.so") #else -- 2.12.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- Notes: This is the host CPU which allowed me to find the missing functionality, but I haven't quite figured out how to test this stuff all the way up to domain capabilities XML. Let's just add it to the low level tests for now. tests/cputest.c | 1 + .../x86_64-cpuid-Core-i7-4510U-guest.xml | 29 +++ .../x86_64-cpuid-Core-i7-4510U-host.xml | 44 +++++ .../x86_64-cpuid-Core-i7-4510U-json.xml | 15 ++ tests/cputestdata/x86_64-cpuid-Core-i7-4510U.json | 203 +++++++++++++++++++++ tests/cputestdata/x86_64-cpuid-Core-i7-4510U.xml | 34 ++++ 6 files changed, 326 insertions(+) create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-4510U-guest.xml create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-4510U-host.xml create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-4510U-json.xml create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-4510U.json create mode 100644 tests/cputestdata/x86_64-cpuid-Core-i7-4510U.xml diff --git a/tests/cputest.c b/tests/cputest.c index 685aca152..5e205c501 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -827,6 +827,7 @@ mymain(void) DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-3740QM", true); DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-3770", true); DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-4600U", true); + DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-4510U", true); DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-5600U", true); DO_TEST_CPUID(VIR_ARCH_X86_64, "Core2-E6850", true); DO_TEST_CPUID(VIR_ARCH_X86_64, "Core2-Q9500", false); diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-4510U-guest.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-4510U-guest.xml new file mode 100644 index 000000000..bcce4ece1 --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-4510U-guest.xml @@ -0,0 +1,29 @@ +<cpu mode='custom' match='exact'> + <model fallback='forbid'>Haswell-noTSX</model> + <vendor>Intel</vendor> + <feature policy='require' name='vme'/> + <feature policy='require' name='ds'/> + <feature policy='require' name='acpi'/> + <feature policy='require' name='ss'/> + <feature policy='require' name='ht'/> + <feature policy='require' name='tm'/> + <feature policy='require' name='pbe'/> + <feature policy='require' name='dtes64'/> + <feature policy='require' name='monitor'/> + <feature policy='require' name='ds_cpl'/> + <feature policy='require' name='vmx'/> + <feature policy='require' name='est'/> + <feature policy='require' name='tm2'/> + <feature policy='require' name='xtpr'/> + <feature policy='require' name='pdcm'/> + <feature policy='require' name='osxsave'/> + <feature policy='require' name='f16c'/> + <feature policy='require' name='rdrand'/> + <feature policy='require' name='arat'/> + <feature policy='require' name='tsc_adjust'/> + <feature policy='require' name='xsaveopt'/> + <feature policy='require' name='pdpe1gb'/> + <feature policy='require' name='abm'/> + <feature policy='require' name='invtsc'/> + <feature policy='disable' name='x2apic'/> +</cpu> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-4510U-host.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-4510U-host.xml new file mode 100644 index 000000000..61bcefbfc --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-4510U-host.xml @@ -0,0 +1,44 @@ +<cpu> + <arch>x86_64</arch> + <model>Westmere</model> + <vendor>Intel</vendor> + <feature name='vme'/> + <feature name='ds'/> + <feature name='acpi'/> + <feature name='ss'/> + <feature name='ht'/> + <feature name='tm'/> + <feature name='pbe'/> + <feature name='pclmuldq'/> + <feature name='dtes64'/> + <feature name='monitor'/> + <feature name='ds_cpl'/> + <feature name='vmx'/> + <feature name='est'/> + <feature name='tm2'/> + <feature name='fma'/> + <feature name='xtpr'/> + <feature name='pdcm'/> + <feature name='pcid'/> + <feature name='movbe'/> + <feature name='tsc-deadline'/> + <feature name='xsave'/> + <feature name='osxsave'/> + <feature name='avx'/> + <feature name='f16c'/> + <feature name='rdrand'/> + <feature name='arat'/> + <feature name='fsgsbase'/> + <feature name='tsc_adjust'/> + <feature name='bmi1'/> + <feature name='avx2'/> + <feature name='smep'/> + <feature name='bmi2'/> + <feature name='erms'/> + <feature name='invpcid'/> + <feature name='xsaveopt'/> + <feature name='pdpe1gb'/> + <feature name='rdtscp'/> + <feature name='abm'/> + <feature name='invtsc'/> +</cpu> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-4510U-json.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-4510U-json.xml new file mode 100644 index 000000000..3ca3b0f24 --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-4510U-json.xml @@ -0,0 +1,15 @@ +<cpu mode='custom' match='exact'> + <model fallback='forbid'>Haswell-noTSX</model> + <vendor>Intel</vendor> + <feature policy='require' name='vme'/> + <feature policy='require' name='ss'/> + <feature policy='require' name='vmx'/> + <feature policy='require' name='f16c'/> + <feature policy='require' name='rdrand'/> + <feature policy='require' name='hypervisor'/> + <feature policy='require' name='arat'/> + <feature policy='require' name='tsc_adjust'/> + <feature policy='require' name='xsaveopt'/> + <feature policy='require' name='pdpe1gb'/> + <feature policy='require' name='abm'/> +</cpu> diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-4510U.json b/tests/cputestdata/x86_64-cpuid-Core-i7-4510U.json new file mode 100644 index 000000000..3cbcdff5c --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-4510U.json @@ -0,0 +1,203 @@ +{ + "return": { + "model": { + "name": "base", + "props": { + "pfthreshold": false, + "pku": false, + "rtm": false, + "tsc_adjust": true, + "tsc-deadline": true, + "xstore-en": false, + "tsc-scale": false, + "sse": true, + "smap": false, + "stepping": 1, + "tce": false, + "kvm_steal_time": true, + "smep": true, + "rdpid": false, + "xcrypt": false, + "sse4_2": true, + "monitor": false, + "sse4_1": true, + "kvm-mmu": false, + "flushbyasid": false, + "kvm-steal-time": true, + "lm": true, + "tsc": true, + "adx": false, + "fxsr": true, + "sha-ni": false, + "tm": false, + "pclmuldq": true, + "xgetbv1": false, + "xstore": false, + "vmcb_clean": false, + "vme": true, + "vendor": "GenuineIntel", + "arat": true, + "ffxsr": false, + "de": true, + "avx512f": false, + "pse": true, + "ds-cpl": false, + "tbm": false, + "ia64": false, + "phe-en": false, + "f16c": true, + "ds": false, + "mpx": false, + "tsc-adjust": true, + "aes": true, + "avx2": true, + "pbe": false, + "cx16": true, + "ds_cpl": false, + "movbe": true, + "perfctr-nb": false, + "nrip_save": false, + "kvm_mmu": false, + "ospke": false, + "avx512ifma": false, + "vmx": true, + "sep": true, + "xsaveopt": true, + "sse4a": false, + "avx512dq": false, + "i64": true, + "avx512-4vnniw": false, + "xsave": true, + "erms": true, + "hle": false, + "nodeid_msr": false, + "est": false, + "svm_lock": false, + "xop": false, + "model-id": "Intel(R) Core(TM) i7-4510U CPU @ 2.00GHz", + "abm": true, + "avx512er": false, + "sse4.1": true, + "sse4.2": true, + "pause-filter": false, + "lahf-lm": true, + "kvm-nopiodelay": true, + "cmp_legacy": false, + "acpi": false, + "fma4": false, + "popcnt": true, + "mmx": true, + "osxsave": false, + "pcommit": false, + "avx512pf": false, + "clwb": false, + "dca": false, + "pdcm": false, + "xcrypt-en": false, + "3dnow": false, + "invtsc": false, + "tm2": false, + "hypervisor": true, + "kvmclock-stable-bit": true, + "fxsr-opt": false, + "pcid": true, + "sse4-1": true, + "sse4-2": true, + "avx512-vpopcntdq": false, + "avx512-4fmaps": false, + "pause_filter": false, + "svm-lock": false, + "rdrand": true, + "nrip-save": false, + "avx512vl": false, + "x2apic": true, + "kvmclock": true, + "pge": true, + "family": 6, + "dtes64": false, + "xd": true, + "kvm_pv_eoi": true, + "ace2": false, + "kvm_pv_unhalt": true, + "xtpr": false, + "perfctr_nb": false, + "avx512bw": false, + "nx": true, + "lwp": false, + "msr": true, + "ace2-en": false, + "decodeassists": false, + "perfctr-core": false, + "pn": false, + "fma": true, + "nodeid-msr": false, + "kvm_asyncpf": true, + "clflush": true, + "cx8": true, + "mce": true, + "avx512cd": false, + "cr8legacy": false, + "mca": true, + "pni": true, + "rdseed": false, + "apic": true, + "fsgsbase": true, + "cmp-legacy": false, + "kvm-pv-unhalt": true, + "rdtscp": true, + "mmxext": false, + "cid": false, + "ssse3": true, + "extapic": false, + "pse36": true, + "mtrr": true, + "ibs": false, + "la57": false, + "avx": true, + "syscall": true, + "umip": false, + "invpcid": true, + "avx512vbmi": false, + "kvm-asyncpf": true, + "vmcb-clean": false, + "pmm": false, + "cmov": true, + "perfctr_core": false, + "misalignsse": false, + "clflushopt": false, + "pat": true, + "lbrv": false, + "3dnowprefetch": false, + "fpu": true, + "pae": true, + "wdt": false, + "tsc_scale": false, + "skinit": false, + "fxsr_opt": false, + "kvm_nopiodelay": true, + "pmm-en": false, + "phe": false, + "3dnowext": false, + "osvw": false, + "ht": false, + "pdpe1gb": true, + "kvm-pv-eoi": true, + "npt": false, + "xsavec": false, + "lahf_lm": true, + "pclmulqdq": true, + "svm": false, + "sse3": true, + "sse2": true, + "ss": true, + "topoext": false, + "smx": false, + "bmi1": true, + "bmi2": true, + "xsaves": false, + "model": 69 + } + } + }, + "id": "model-expansion" +} diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-4510U.xml b/tests/cputestdata/x86_64-cpuid-Core-i7-4510U.xml new file mode 100644 index 000000000..3ab114775 --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-4510U.xml @@ -0,0 +1,34 @@ +<!-- Intel(R) Core(TM) i7-4510U CPU @ 2.00GHz --> +<cpudata arch='x86'> + <cpuid eax_in='0x00000000' ecx_in='0x00' eax='0x0000000d' ebx='0x756e6547' ecx='0x6c65746e' edx='0x49656e69'/> + <cpuid eax_in='0x00000001' ecx_in='0x00' eax='0x00040651' ebx='0x01100800' ecx='0x7fdafbbf' edx='0xbfebfbff'/> + <cpuid eax_in='0x00000002' ecx_in='0x00' eax='0x76036301' ebx='0x00f0b5ff' ecx='0x00000000' edx='0x00c10000'/> + <cpuid eax_in='0x00000003' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/> + <cpuid eax_in='0x00000004' ecx_in='0x00' eax='0x1c004121' ebx='0x01c0003f' ecx='0x0000003f' edx='0x00000000'/> + <cpuid eax_in='0x00000004' ecx_in='0x01' eax='0x1c004122' ebx='0x01c0003f' ecx='0x0000003f' edx='0x00000000'/> + <cpuid eax_in='0x00000004' ecx_in='0x02' eax='0x1c004143' ebx='0x01c0003f' ecx='0x000001ff' edx='0x00000000'/> + <cpuid eax_in='0x00000004' ecx_in='0x03' eax='0x1c03c163' ebx='0x03c0003f' ecx='0x00000fff' edx='0x00000006'/> + <cpuid eax_in='0x00000005' ecx_in='0x00' eax='0x00000040' ebx='0x00000040' ecx='0x00000003' edx='0x11142120'/> + <cpuid eax_in='0x00000006' ecx_in='0x00' eax='0x00000077' ebx='0x00000002' ecx='0x00000009' edx='0x00000000'/> + <cpuid eax_in='0x00000007' ecx_in='0x00' eax='0x00000000' ebx='0x000027ab' ecx='0x00000000' edx='0x00000000'/> + <cpuid eax_in='0x00000008' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/> + <cpuid eax_in='0x00000009' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/> + <cpuid eax_in='0x0000000a' ecx_in='0x00' eax='0x07300403' ebx='0x00000000' ecx='0x00000000' edx='0x00000603'/> + <cpuid eax_in='0x0000000b' ecx_in='0x00' eax='0x00000001' ebx='0x00000002' ecx='0x00000100' edx='0x00000001'/> + <cpuid eax_in='0x0000000b' ecx_in='0x01' eax='0x00000004' ebx='0x00000004' ecx='0x00000201' edx='0x00000001'/> + <cpuid eax_in='0x0000000c' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/> + <cpuid eax_in='0x0000000d' ecx_in='0x00' eax='0x00000007' ebx='0x00000340' ecx='0x00000340' edx='0x00000000'/> + <cpuid eax_in='0x0000000d' ecx_in='0x01' eax='0x00000001' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/> + <cpuid eax_in='0x0000000d' ecx_in='0x02' eax='0x00000100' ebx='0x00000240' ecx='0x00000000' edx='0x00000000'/> + <cpuid eax_in='0x80000000' ecx_in='0x00' eax='0x80000008' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/> + <cpuid eax_in='0x80000001' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000021' edx='0x2c100800'/> + <cpuid eax_in='0x80000002' ecx_in='0x00' eax='0x65746e49' ebx='0x2952286c' ecx='0x726f4320' edx='0x4d542865'/> + <cpuid eax_in='0x80000003' ecx_in='0x00' eax='0x37692029' ebx='0x3135342d' ecx='0x43205530' edx='0x40205550'/> + <cpuid eax_in='0x80000004' ecx_in='0x00' eax='0x302e3220' ebx='0x7a484730' ecx='0x00000000' edx='0x00000000'/> + <cpuid eax_in='0x80000005' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/> + <cpuid eax_in='0x80000006' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x01006040' edx='0x00000000'/> + <cpuid eax_in='0x80000007' ecx_in='0x00' eax='0x00000000' ebx='0x00000000' ecx='0x00000000' edx='0x00000100'/> + <cpuid eax_in='0x80000008' ecx_in='0x00' eax='0x00003027' ebx='0x00000000' ecx='0x00000000' edx='0x00000000'/> + <cpuid eax_in='0x80860000' ecx_in='0x00' eax='0x00000007' ebx='0x00000340' ecx='0x00000340' edx='0x00000000'/> + <cpuid eax_in='0xc0000000' ecx_in='0x00' eax='0x00000007' ebx='0x00000340' ecx='0x00000340' edx='0x00000000'/> +</cpudata> -- 2.12.0

On Wed, Mar 08, 2017 at 02:46:21PM +0100, Jiri Denemark wrote:
One of the main reasons for introducing host-model CPU definition in a domain capabilities XML was the inability to express disabled features in a host capabilities XML. That is, when a host CPU is, e.g., Haswell without x2apic support, host capabilities XML will have to report it as Westmere + a bunch of additional features., but we really want to use Haswell - x2apic when creating a host-model CPU.
Unfortunately, I somehow forgot to do the last step and the code would just copy the CPU definition found in the host capabilities XML. This changed recently for new QEMU versions which allow us to query host CPU, but any slightly older QEMU will not benefit from any change I did. This patch makes sure the right CPU model is filled in the domain capabilities even with old QEMU.
The issue was reported in https://bugzilla.redhat.com/show_bug.cgi?id=1426456
Jiri Denemark (7): Do not format <arch> in guest CPU XML cpu: Replace cpuNodeData with virCPUGetHost cpu: Add virCPUType parameter to virCPUGetHost cpu: Add list of allowed CPU models to virCPUGetHost qemu: Refactor virQEMUCapsInitCPU qemu: Report better host-model CPUs in domain caps cputest: New test for Intel Core i7-4510U
ACK series Jan
participants (2)
-
Jiri Denemark
-
Ján Tomko