]> xenbits.xensource.com Git - libvirt.git/commitdiff
cputest: Don't test cpuGuestData
authorJiri Denemark <jdenemar@redhat.com>
Thu, 10 Nov 2016 08:41:17 +0000 (09:41 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 15 Nov 2016 14:49:16 +0000 (15:49 +0100)
The API is no longer used anywhere else since it was replaced by a much
saner work flow utilizing new APIs that work on virCPUDefPtr directly:
virCPUCompare, virCPUUpdate, and virCPUTranslate.

Not testing the new work flow caused some bugs to be hidden. This patch
reveals them, but doesn't attempt to fix them. To make sure all test
still pass after this patch, all affected test results are modified to
pretend the tests succeeded. All of the bugs will be fixed in the
following commits and the artificial modifications will be reverted.

The following is the list of bugs in the new CPU model work flow:

- a guest CPU with mode='custom' and missing <vendor/> gets the vendor
  copied from host's CPU (the vendor should only be copied to host-model
  CPUs):
    DO_TEST_UPDATE("x86", "host", "min", VIR_CPU_COMPARE_IDENTICAL)
    DO_TEST_UPDATE("x86", "host", "pentium3", VIR_CPU_COMPARE_IDENTICAL)
    DO_TEST_GUESTCPU("x86", "host-better", "pentium3", NULL, 0)

- when a guest CPU with mode='custom' needs to be translated into
  another model because the original model is not supported by a
  hypervisor, the result will have its vendor set to the vendor of the
  original CPU model as specified in cpu_map.xml even if the original
  guest CPU XML didn't contain <vendor/>:
    DO_TEST_GUESTCPU("x86", "host", "guest", model486, 0)
    DO_TEST_GUESTCPU("x86", "host", "guest", models, 0)
    DO_TEST_GUESTCPU("x86", "host-Haswell-noTSX", "Haswell-noTSX",
                     haswell, 0)

- legacy POWERx_v* model names are not recognized:
    DO_TEST_GUESTCPU("ppc64", "host", "guest-legacy", ppc_models, 0)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
14 files changed:
tests/cputest.c
tests/cputestdata/ppc64-host+guest,ppc_models-result.xml
tests/cputestdata/ppc64-host+guest-legacy,ppc_models-result.xml
tests/cputestdata/x86-host+guest,model486-result.xml
tests/cputestdata/x86-host+guest,models-result.xml
tests/cputestdata/x86-host+guest-result.xml
tests/cputestdata/x86-host+host+host-model,models-result.xml
tests/cputestdata/x86-host+penryn-force-result.xml
tests/cputestdata/x86-host+strict-force-extra-result.xml
tests/cputestdata/x86-host-Haswell-noTSX+Haswell,haswell-result.xml
tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX,haswell-result.xml
tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX-result.xml
tests/cputestdata/x86-host-better+pentium3-result.xml
tests/cputestdata/x86-host-worse+guest-result.xml

index 6aebfb0093acbe2a52221adca3c791fe8290a160..1d7f6bc56243b01a3b24ab1a23d93f09ea0a3c9c 100644 (file)
@@ -237,14 +237,12 @@ cpuTestCompare(const void *arg)
 
 
 static int
-cpuTestGuestData(const void *arg)
+cpuTestGuestCPU(const void *arg)
 {
     const struct data *data = arg;
     int ret = -2;
     virCPUDefPtr host = NULL;
     virCPUDefPtr cpu = NULL;
-    virCPUDefPtr guest = NULL;
-    virCPUDataPtr guestData = NULL;
     virCPUCompareResult cmpResult;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     char *result = NULL;
@@ -253,22 +251,15 @@ cpuTestGuestData(const void *arg)
         !(cpu = cpuTestLoadXML(data->arch, data->name)))
         goto cleanup;
 
-    cmpResult = cpuGuestData(host, cpu, &guestData, NULL);
+    cmpResult = virCPUCompare(host->arch, host, cpu, false);
     if (cmpResult == VIR_CPU_COMPARE_ERROR ||
         cmpResult == VIR_CPU_COMPARE_INCOMPATIBLE) {
         ret = -1;
         goto cleanup;
     }
 
-    if (VIR_ALLOC(guest) < 0)
-        goto cleanup;
-
-    guest->arch = host->arch;
-    guest->type = VIR_CPU_TYPE_GUEST;
-    guest->match = VIR_CPU_MATCH_EXACT;
-    guest->fallback = cpu->fallback;
-    if (cpuDecode(guest, guestData, data->models,
-                  data->nmodels, NULL) < 0) {
+    if (virCPUUpdate(host->arch, cpu, host) < 0 ||
+        virCPUTranslate(host->arch, cpu, data->models, data->nmodels) < 0) {
         ret = -1;
         goto cleanup;
     }
@@ -284,17 +275,15 @@ cpuTestGuestData(const void *arg)
     }
     result = virBufferContentAndReset(&buf);
 
-    if (cpuTestCompareXML(data->arch, guest, result, false) < 0)
+    if (cpuTestCompareXML(data->arch, cpu, result, false) < 0)
         goto cleanup;
 
     ret = 0;
 
  cleanup:
     VIR_FREE(result);
-    cpuDataFree(guestData);
     virCPUDefFree(host);
     virCPUDefFree(cpu);
-    virCPUDefFree(guest);
 
     if (ret == data->result) {
         /* We got the result we expected, whether it was
@@ -656,8 +645,8 @@ mymain(void)
             host "/" feature " (" #result ")",                          \
             host, feature, NULL, 0, 0, result)
 
-#define DO_TEST_GUESTDATA(arch, host, cpu, models, result)              \
-    DO_TEST(arch, cpuTestGuestData,                                     \
+#define DO_TEST_GUESTCPU(arch, host, cpu, models, result)               \
+    DO_TEST(arch, cpuTestGuestCPU,                                      \
             host "/" cpu " (" #models ")",                              \
             host, cpu, models,                                          \
             models == NULL ? 0 : sizeof(models) / sizeof(char *),       \
@@ -787,27 +776,27 @@ mymain(void)
     DO_TEST_HASFEATURE("x86", "host", "foo", FAIL);
 
     /* computing guest data and decoding the data into a guest CPU XML */
-    DO_TEST_GUESTDATA("x86", "host", "guest", NULL, 0);
-    DO_TEST_GUESTDATA("x86", "host-better", "pentium3", NULL, 0);
-    DO_TEST_GUESTDATA("x86", "host-worse", "guest", NULL, 0);
-    DO_TEST_GUESTDATA("x86", "host", "strict-force-extra", NULL, 0);
-    DO_TEST_GUESTDATA("x86", "host", "penryn-force", NULL, 0);
-    DO_TEST_GUESTDATA("x86", "host", "guest", model486, 0);
-    DO_TEST_GUESTDATA("x86", "host", "guest", models, 0);
-    DO_TEST_GUESTDATA("x86", "host", "guest", nomodel, -1);
-    DO_TEST_GUESTDATA("x86", "host", "guest-nofallback", models, /*-1*/ -2);
-    DO_TEST_GUESTDATA("x86", "host", "host+host-model", models, 0);
-    DO_TEST_GUESTDATA("x86", "host", "host+host-model-nofallback", models, /*-1*/ -2);
-    DO_TEST_GUESTDATA("x86", "host-Haswell-noTSX", "Haswell", haswell, 0);
-    DO_TEST_GUESTDATA("x86", "host-Haswell-noTSX", "Haswell-noTSX", haswell, 0);
-    DO_TEST_GUESTDATA("x86", "host-Haswell-noTSX", "Haswell-noTSX-nofallback", haswell, /*-1*/ -2);
-    DO_TEST_GUESTDATA("x86", "host-Haswell-noTSX", "Haswell-noTSX", NULL, 0);
-
-    DO_TEST_GUESTDATA("ppc64", "host", "guest", ppc_models, 0);
-    DO_TEST_GUESTDATA("ppc64", "host", "guest-nofallback", ppc_models, -1);
-    DO_TEST_GUESTDATA("ppc64", "host", "guest-legacy", ppc_models, 0);
-    DO_TEST_GUESTDATA("ppc64", "host", "guest-legacy-incompatible", ppc_models, -1);
-    DO_TEST_GUESTDATA("ppc64", "host", "guest-legacy-invalid", ppc_models, -1);
+    DO_TEST_GUESTCPU("x86", "host", "guest", NULL, 0);
+    DO_TEST_GUESTCPU("x86", "host-better", "pentium3", NULL, 0);
+    DO_TEST_GUESTCPU("x86", "host-worse", "guest", NULL, 0);
+    DO_TEST_GUESTCPU("x86", "host", "strict-force-extra", NULL, 0);
+    DO_TEST_GUESTCPU("x86", "host", "penryn-force", NULL, 0);
+    DO_TEST_GUESTCPU("x86", "host", "guest", model486, 0);
+    DO_TEST_GUESTCPU("x86", "host", "guest", models, 0);
+    DO_TEST_GUESTCPU("x86", "host", "guest", nomodel, -1);
+    DO_TEST_GUESTCPU("x86", "host", "guest-nofallback", models, -1);
+    DO_TEST_GUESTCPU("x86", "host", "host+host-model", models, 0);
+    DO_TEST_GUESTCPU("x86", "host", "host+host-model-nofallback", models, -1);
+    DO_TEST_GUESTCPU("x86", "host-Haswell-noTSX", "Haswell", haswell, 0);
+    DO_TEST_GUESTCPU("x86", "host-Haswell-noTSX", "Haswell-noTSX", haswell, 0);
+    DO_TEST_GUESTCPU("x86", "host-Haswell-noTSX", "Haswell-noTSX-nofallback", haswell, -1);
+    DO_TEST_GUESTCPU("x86", "host-Haswell-noTSX", "Haswell-noTSX", NULL, 0);
+
+    DO_TEST_GUESTCPU("ppc64", "host", "guest", ppc_models, 0);
+    DO_TEST_GUESTCPU("ppc64", "host", "guest-nofallback", ppc_models, -1);
+    DO_TEST_GUESTCPU("ppc64", "host", "guest-legacy", ppc_models, /*0*/ -1);
+    DO_TEST_GUESTCPU("ppc64", "host", "guest-legacy-incompatible", ppc_models, -1);
+    DO_TEST_GUESTCPU("ppc64", "host", "guest-legacy-invalid", ppc_models, -1);
 
     DO_TEST_CPUID("x86", "A10-5800K", true);
     DO_TEST_CPUID("x86", "Atom-D510", false);
index 3548c0ef6742bf9fca7d8054a76618858b46e740..7fac4b79c72b8ef7adbb086712bfca0054bf1716 100644 (file)
@@ -1,5 +1,3 @@
 <cpu mode='custom' match='exact'>
-  <arch>ppc64</arch>
   <model fallback='allow'>POWER7</model>
-  <vendor>IBM</vendor>
 </cpu>
index 3548c0ef6742bf9fca7d8054a76618858b46e740..7fac4b79c72b8ef7adbb086712bfca0054bf1716 100644 (file)
@@ -1,5 +1,3 @@
 <cpu mode='custom' match='exact'>
-  <arch>ppc64</arch>
   <model fallback='allow'>POWER7</model>
-  <vendor>IBM</vendor>
 </cpu>
index 8bd425d203f99cc68ecec4448b268199d8358b3a..88df4679b0c2ae9d1f0658adbeb18708e279f0f0 100644 (file)
@@ -1,6 +1,7 @@
 <cpu mode='custom' match='exact'>
-  <arch>x86_64</arch>
   <model fallback='allow'>486</model>
+  <vendor>Intel</vendor>
+  <topology sockets='2' cores='4' threads='1'/>
   <feature policy='require' name='de'/>
   <feature policy='require' name='tsc'/>
   <feature policy='require' name='msr'/>
@@ -19,9 +20,9 @@
   <feature policy='require' name='mmx'/>
   <feature policy='require' name='fxsr'/>
   <feature policy='require' name='sse2'/>
-  <feature policy='require' name='pbe'/>
+  <feature policy='force' name='pbe'/>
   <feature policy='require' name='pni'/>
-  <feature policy='require' name='monitor'/>
+  <feature policy='force' name='monitor'/>
   <feature policy='require' name='ssse3'/>
   <feature policy='require' name='cx16'/>
   <feature policy='require' name='xtpr'/>
   <feature policy='require' name='syscall'/>
   <feature policy='require' name='nx'/>
   <feature policy='require' name='lm'/>
-  <feature policy='require' name='3dnowext'/>
+  <feature policy='force' name='3dnowext'/>
   <feature policy='require' name='lahf_lm'/>
-  <feature policy='require' name='svm'/>
+  <feature policy='force' name='svm'/>
   <feature policy='disable' name='vme'/>
+  <feature policy='disable' name='sse4.2'/>
+  <feature policy='disable' name='3dnow'/>
+  <feature policy='disable' name='vmx'/>
+  <feature policy='disable' name='ds_cpl'/>
+  <feature policy='disable' name='sse'/>
+  <feature policy='forbid' name='popcnt'/>
 </cpu>
index 6cd0668326f3b19888e80732459fd39d2a812013..e7a77c27e45de8c14b9441d30d15c5632f75182a 100644 (file)
@@ -1,13 +1,18 @@
 <cpu mode='custom' match='exact'>
-  <arch>x86_64</arch>
   <model fallback='allow'>Nehalem</model>
-  <feature policy='require' name='pbe'/>
-  <feature policy='require' name='monitor'/>
+  <vendor>Intel</vendor>
+  <topology sockets='2' cores='4' threads='1'/>
+  <feature policy='force' name='pbe'/>
+  <feature policy='force' name='monitor'/>
   <feature policy='require' name='xtpr'/>
   <feature policy='require' name='dca'/>
-  <feature policy='require' name='3dnowext'/>
-  <feature policy='require' name='svm'/>
+  <feature policy='force' name='3dnowext'/>
+  <feature policy='force' name='svm'/>
   <feature policy='disable' name='sse'/>
   <feature policy='disable' name='sse4.2'/>
-  <feature policy='disable' name='popcnt'/>
+  <feature policy='forbid' name='popcnt'/>
+  <feature policy='disable' name='3dnow'/>
+  <feature policy='require' name='ssse3'/>
+  <feature policy='disable' name='vmx'/>
+  <feature policy='disable' name='ds_cpl'/>
 </cpu>
index 6082b7b99221a670436be609601e6a7d6c786966..137a3d6647f47db83caf922e89b3562e62824a1b 100644 (file)
@@ -1,11 +1,17 @@
 <cpu mode='custom' match='exact'>
-  <arch>x86_64</arch>
   <model fallback='allow'>Penryn</model>
-  <feature policy='require' name='pbe'/>
-  <feature policy='require' name='monitor'/>
-  <feature policy='require' name='xtpr'/>
+  <topology sockets='2' cores='4' threads='1'/>
   <feature policy='require' name='dca'/>
-  <feature policy='require' name='3dnowext'/>
-  <feature policy='require' name='svm'/>
+  <feature policy='require' name='xtpr'/>
+  <feature policy='disable' name='sse4.2'/>
+  <feature policy='disable' name='3dnow'/>
+  <feature policy='require' name='ssse3'/>
+  <feature policy='disable' name='vmx'/>
+  <feature policy='disable' name='ds_cpl'/>
   <feature policy='disable' name='sse'/>
+  <feature policy='force' name='monitor'/>
+  <feature policy='force' name='pbe'/>
+  <feature policy='force' name='3dnowext'/>
+  <feature policy='force' name='svm'/>
+  <feature policy='forbid' name='popcnt'/>
 </cpu>
index 63d5e9075f507c3d7a01cebeb7eb1ec3a5d4dda1..4be4701c6e66094d7d12ed085a796fdba3d74a75 100644 (file)
@@ -1,5 +1,4 @@
 <cpu mode='custom' match='exact'>
-  <arch>x86_64</arch>
   <model fallback='allow'>core2duo</model>
   <vendor>Intel</vendor>
   <feature policy='require' name='ds'/>
@@ -17,4 +16,6 @@
   <feature policy='require' name='dca'/>
   <feature policy='require' name='sse4.1'/>
   <feature policy='require' name='lahf_lm'/>
+  <feature policy='require' name='monitor'/>
+  <feature policy='require' name='vme'/>
 </cpu>
index ef0a2c0504d65ded53a11c8f591479a364ee4649..bb624c01c74e4123fb2914f19663fcc9a4f9d1e1 100644 (file)
@@ -1,6 +1,5 @@
 <cpu mode='custom' match='exact'>
-  <arch>x86_64</arch>
   <model fallback='allow'>Penryn</model>
-  <feature policy='require' name='sse4.2'/>
-  <feature policy='require' name='popcnt'/>
+  <feature policy='force' name='popcnt'/>
+  <feature policy='force' name='sse4.2'/>
 </cpu>
index 958d458fea220dfcbb25bff92024fee7ddd9778e..74b33279db589c1a76b67f4f89c1ccf3c7a56b0c 100644 (file)
@@ -1,19 +1,18 @@
-<cpu mode='custom' match='exact'>
-  <arch>x86_64</arch>
+<cpu mode='custom' match='strict'>
   <model fallback='allow'>Penryn</model>
-  <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='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='dca'/>
-  <feature policy='require' name='3dnow'/>
+  <feature policy='require' name='xtpr'/>
+  <feature policy='require' name='tm2'/>
+  <feature policy='require' name='est'/>
+  <feature policy='require' name='vmx'/>
+  <feature policy='require' name='ds_cpl'/>
+  <feature policy='require' name='monitor'/>
+  <feature policy='require' name='pbe'/>
+  <feature policy='require' name='tm'/>
+  <feature policy='require' name='ht'/>
+  <feature policy='require' name='ss'/>
+  <feature policy='require' name='acpi'/>
+  <feature policy='require' name='ds'/>
+  <feature policy='require' name='vme'/>
+  <feature policy='force' name='3dnow'/>
 </cpu>
index dfdca1370a37f15a059b7d5f71d996a59796694d..2dbe06c314b1ccad621b0386a4c887629eccea95 100644 (file)
@@ -1,6 +1,6 @@
 <cpu mode='custom' match='exact'>
-  <arch>x86_64</arch>
   <model fallback='allow'>Haswell</model>
-  <feature policy='disable' name='hle'/>
+  <topology sockets='1' cores='2' threads='2'/>
   <feature policy='disable' name='rtm'/>
+  <feature policy='disable' name='hle'/>
 </cpu>
index dfdca1370a37f15a059b7d5f71d996a59796694d..5902f6c76f6cfbc66060e684075ed653db4e4c1a 100644 (file)
@@ -1,6 +1,7 @@
 <cpu mode='custom' match='exact'>
-  <arch>x86_64</arch>
   <model fallback='allow'>Haswell</model>
+  <vendor>Intel</vendor>
+  <topology sockets='1' cores='2' threads='2'/>
   <feature policy='disable' name='hle'/>
   <feature policy='disable' name='rtm'/>
 </cpu>
index f5a67fb6b1ed62419b17787cc89348fea65dcd4a..3b7408964763b4a7e0e1a44c7b06c531570ea416 100644 (file)
@@ -1,4 +1,4 @@
 <cpu mode='custom' match='exact'>
-  <arch>x86_64</arch>
   <model fallback='allow'>Haswell-noTSX</model>
+  <topology sockets='1' cores='2' threads='2'/>
 </cpu>
index a37b36890dde1da9c88b089f015aadfff81c3361..12336daf900ce7ce6f9555450675ac2b66820c31 100644 (file)
@@ -1,18 +1,18 @@
 <cpu mode='custom' match='exact'>
-  <arch>x86_64</arch>
   <model fallback='allow'>Nehalem</model>
-  <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='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'/>
+  <vendor>Intel</vendor>
   <feature policy='require' name='dca'/>
+  <feature policy='require' name='xtpr'/>
+  <feature policy='require' name='tm2'/>
+  <feature policy='require' name='est'/>
+  <feature policy='require' name='vmx'/>
+  <feature policy='require' name='ds_cpl'/>
+  <feature policy='require' name='monitor'/>
+  <feature policy='require' name='pbe'/>
+  <feature policy='require' name='tm'/>
+  <feature policy='require' name='ht'/>
+  <feature policy='require' name='ss'/>
+  <feature policy='require' name='acpi'/>
+  <feature policy='require' name='ds'/>
+  <feature policy='require' name='vme'/>
 </cpu>
index 6b9c74add432da054b7c7f05e13f3db7cd5a6470..2edc8756c44f832e3c15ed6f21ccebd7c937171a 100644 (file)
@@ -1,9 +1,17 @@
 <cpu mode='custom' match='exact'>
-  <arch>x86_64</arch>
   <model fallback='allow'>Penryn</model>
-  <feature policy='require' name='pbe'/>
-  <feature policy='require' name='monitor'/>
-  <feature policy='require' name='3dnowext'/>
-  <feature policy='require' name='svm'/>
+  <topology sockets='2' cores='4' threads='1'/>
+  <feature policy='disable' name='dca'/>
+  <feature policy='disable' name='xtpr'/>
+  <feature policy='disable' name='sse4.2'/>
+  <feature policy='disable' name='3dnow'/>
+  <feature policy='require' name='ssse3'/>
+  <feature policy='disable' name='vmx'/>
+  <feature policy='disable' name='ds_cpl'/>
   <feature policy='disable' name='sse'/>
+  <feature policy='force' name='monitor'/>
+  <feature policy='force' name='pbe'/>
+  <feature policy='force' name='3dnowext'/>
+  <feature policy='force' name='svm'/>
+  <feature policy='forbid' name='popcnt'/>
 </cpu>