提交 a19696b5 编写于 作者: J Jiri Denemark

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: NJiri Denemark <jdenemar@redhat.com>
上级 d46a1aa4
......@@ -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);
......
<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'/>
......
<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'/>
......
<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'/>
......
<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'/>
......
<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'/>
......
<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'/>
......
<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'/>
......
<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'/>
......
<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'/>
......
<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>
<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>
<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'/>
......
<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'/>
......
<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'/>
......
<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'/>
......
<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'/>
......
<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'/>
......
<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'/>
......
<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'/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册