1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

cputest: Test virQEMUCapsInitCPUModel

The original test didn't use family/model numbers to make better
decisions about the CPU model and thus mis-detected the model in the two
cases which are modified in this commit. The detected CPU models now
match those obtained from raw CPUID data.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jiri Denemark 2017-02-13 10:33:52 +01:00
parent d46a1aa4d8
commit a19696b592
20 changed files with 48 additions and 14 deletions

View File

@ -43,7 +43,9 @@
#if WITH_QEMU && WITH_YAJL
# include "testutilsqemu.h"
# include "qemumonitortestutils.h"
# include "qemu/qemu_monitor_json.h"
# define __QEMU_CAPSRIV_H_ALLOW__
# include "qemu/qemu_capspriv.h"
# undef __QEMU_CAPSRIV_H_ALLOW__
#endif
#define VIR_FROM_THIS VIR_FROM_CPU
@ -517,14 +519,15 @@ static int
cpuTestJSONCPUID(const void *arg)
{
const struct data *data = arg;
virCPUDataPtr cpuData = NULL;
qemuMonitorCPUModelInfoPtr model = NULL;
virQEMUCapsPtr qemuCaps = NULL;
virCPUDefPtr cpu = NULL;
qemuMonitorTestPtr testMon = NULL;
char *json = NULL;
char *result = NULL;
int ret = -1;
if (virAsprintf(&json, "%s/cputestdata/%s-cpuid-%s.json",
if (virAsprintf(&json, "%s/cputestdata/%s-cpuid-%s.json.new",
abs_srcdir, virArchToString(data->arch), data->host) < 0 ||
virAsprintf(&result, "cpuid-%s-json", data->host) < 0)
goto cleanup;
@ -532,26 +535,35 @@ cpuTestJSONCPUID(const void *arg)
if (!(testMon = qemuMonitorTestNewFromFile(json, driver.xmlopt, true)))
goto cleanup;
if (qemuMonitorJSONGetCPUx86Data(qemuMonitorTestGetMonitor(testMon),
"feature-words", &cpuData) < 0)
if (qemuMonitorGetCPUModelExpansion(qemuMonitorTestGetMonitor(testMon),
QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC,
"host", &model) < 0)
goto cleanup;
if (!(qemuCaps = virQEMUCapsNew()))
goto cleanup;
virQEMUCapsSetArch(qemuCaps, data->arch);
virQEMUCapsSetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM, model);
model = NULL;
if (VIR_ALLOC(cpu) < 0)
goto cleanup;
cpu->arch = cpuData->arch;
cpu->arch = data->arch;
cpu->type = VIR_CPU_TYPE_GUEST;
cpu->match = VIR_CPU_MATCH_EXACT;
cpu->fallback = VIR_CPU_FALLBACK_FORBID;
if (cpuDecode(cpu, cpuData, NULL, 0, NULL) < 0)
if (virQEMUCapsInitCPUModel(qemuCaps, VIR_DOMAIN_VIRT_KVM, cpu) != 0)
goto cleanup;
ret = cpuTestCompareXML(data->arch, cpu, result, false);
cleanup:
qemuMonitorCPUModelInfoFree(model);
virObjectUnref(qemuCaps);
qemuMonitorTestFree(testMon);
virCPUDataFree(cpuData);
virCPUDefFree(cpu);
VIR_FREE(result);
VIR_FREE(json);

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>Opteron_G5</model>
<vendor>AMD</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='hypervisor'/>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>SandyBridge</model>
<vendor>Intel</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='pcid'/>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>SandyBridge</model>
<vendor>Intel</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='pcid'/>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>Haswell</model>
<vendor>Intel</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='vmx'/>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>Skylake-Client</model>
<vendor>Intel</vendor>
<feature policy='require' name='ss'/>
<feature policy='require' name='hypervisor'/>
<feature policy='require' name='tsc_adjust'/>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>SandyBridge</model>
<vendor>Intel</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='pcid'/>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>IvyBridge</model>
<vendor>Intel</vendor>
<feature policy='require' name='ss'/>
<feature policy='require' name='vmx'/>
<feature policy='require' name='pcid'/>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>IvyBridge</model>
<vendor>Intel</vendor>
<feature policy='require' name='ss'/>
<feature policy='require' name='pcid'/>
<feature policy='require' name='hypervisor'/>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>Haswell-noTSX</model>
<vendor>Intel</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='vmx'/>

View File

@ -1,12 +1,16 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>Skylake-Client</model>
<model fallback='forbid'>Broadwell</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='disable' name='mpx'/>
<feature policy='disable' name='xsavec'/>
<feature policy='disable' name='xgetbv1'/>
<feature policy='require' name='abm'/>
</cpu>

View File

@ -1,11 +1,12 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>Penryn</model>
<model fallback='forbid'>Conroe</model>
<vendor>Intel</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='cx16'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>
<feature policy='require' name='hypervisor'/>
<feature policy='require' name='tsc_adjust'/>
<feature policy='disable' name='sse4.1'/>
</cpu>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>Opteron_G3</model>
<vendor>AMD</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>Opteron_G4</model>
<vendor>AMD</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='tsc-deadline'/>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>Opteron_G3</model>
<vendor>AMD</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='x2apic'/>
<feature policy='require' name='hypervisor'/>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>Skylake-Client</model>
<vendor>Intel</vendor>
<feature policy='require' name='ss'/>
<feature policy='require' name='vmx'/>
<feature policy='require' name='hypervisor'/>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>Haswell-noTSX</model>
<vendor>Intel</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='f16c'/>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>Haswell-noTSX</model>
<vendor>Intel</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='vmx'/>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>SandyBridge</model>
<vendor>Intel</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='pcid'/>

View File

@ -1,6 +1,7 @@
<cpu mode='custom' match='exact'>
<arch>x86_64</arch>
<model fallback='forbid'>Nehalem</model>
<vendor>Intel</vendor>
<feature policy='require' name='vme'/>
<feature policy='require' name='ss'/>
<feature policy='require' name='x2apic'/>