From 509a4a40f96926e95e809f563e1cfed06d9f2cee Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Thu, 10 Nov 2016 09:41:17 +0100 Subject: [PATCH] cputest: Don't test cpuGuestData 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 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 : 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 --- tests/cputest.c | 65 ++++++++----------- .../ppc64-host+guest,ppc_models-result.xml | 2 - ...64-host+guest-legacy,ppc_models-result.xml | 2 - .../x86-host+guest,model486-result.xml | 17 +++-- .../x86-host+guest,models-result.xml | 17 +++-- tests/cputestdata/x86-host+guest-result.xml | 18 +++-- ...x86-host+host+host-model,models-result.xml | 3 +- .../x86-host+penryn-force-result.xml | 5 +- .../x86-host+strict-force-extra-result.xml | 31 +++++---- ...t-Haswell-noTSX+Haswell,haswell-result.xml | 4 +- ...ell-noTSX+Haswell-noTSX,haswell-result.xml | 3 +- ...ost-Haswell-noTSX+Haswell-noTSX-result.xml | 2 +- .../x86-host-better+pentium3-result.xml | 28 ++++---- .../x86-host-worse+guest-result.xml | 18 +++-- 14 files changed, 113 insertions(+), 102 deletions(-) diff --git a/tests/cputest.c b/tests/cputest.c index 6aebfb0093..1d7f6bc562 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -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_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_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("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); diff --git a/tests/cputestdata/ppc64-host+guest,ppc_models-result.xml b/tests/cputestdata/ppc64-host+guest,ppc_models-result.xml index 3548c0ef67..7fac4b79c7 100644 --- a/tests/cputestdata/ppc64-host+guest,ppc_models-result.xml +++ b/tests/cputestdata/ppc64-host+guest,ppc_models-result.xml @@ -1,5 +1,3 @@ - ppc64 POWER7 - IBM diff --git a/tests/cputestdata/ppc64-host+guest-legacy,ppc_models-result.xml b/tests/cputestdata/ppc64-host+guest-legacy,ppc_models-result.xml index 3548c0ef67..7fac4b79c7 100644 --- a/tests/cputestdata/ppc64-host+guest-legacy,ppc_models-result.xml +++ b/tests/cputestdata/ppc64-host+guest-legacy,ppc_models-result.xml @@ -1,5 +1,3 @@ - ppc64 POWER7 - IBM diff --git a/tests/cputestdata/x86-host+guest,model486-result.xml b/tests/cputestdata/x86-host+guest,model486-result.xml index 8bd425d203..88df4679b0 100644 --- a/tests/cputestdata/x86-host+guest,model486-result.xml +++ b/tests/cputestdata/x86-host+guest,model486-result.xml @@ -1,6 +1,7 @@ - x86_64 486 + Intel + @@ -19,9 +20,9 @@ - + - + @@ -30,8 +31,14 @@ - + - + + + + + + + diff --git a/tests/cputestdata/x86-host+guest,models-result.xml b/tests/cputestdata/x86-host+guest,models-result.xml index 6cd0668326..e7a77c27e4 100644 --- a/tests/cputestdata/x86-host+guest,models-result.xml +++ b/tests/cputestdata/x86-host+guest,models-result.xml @@ -1,13 +1,18 @@ - x86_64 Nehalem - - + Intel + + + - - + + - + + + + + diff --git a/tests/cputestdata/x86-host+guest-result.xml b/tests/cputestdata/x86-host+guest-result.xml index 6082b7b992..137a3d6647 100644 --- a/tests/cputestdata/x86-host+guest-result.xml +++ b/tests/cputestdata/x86-host+guest-result.xml @@ -1,11 +1,17 @@ - x86_64 Penryn - - - + - - + + + + + + + + + + + diff --git a/tests/cputestdata/x86-host+host+host-model,models-result.xml b/tests/cputestdata/x86-host+host+host-model,models-result.xml index 63d5e9075f..4be4701c6e 100644 --- a/tests/cputestdata/x86-host+host+host-model,models-result.xml +++ b/tests/cputestdata/x86-host+host+host-model,models-result.xml @@ -1,5 +1,4 @@ - x86_64 core2duo Intel @@ -17,4 +16,6 @@ + + diff --git a/tests/cputestdata/x86-host+penryn-force-result.xml b/tests/cputestdata/x86-host+penryn-force-result.xml index ef0a2c0504..bb624c01c7 100644 --- a/tests/cputestdata/x86-host+penryn-force-result.xml +++ b/tests/cputestdata/x86-host+penryn-force-result.xml @@ -1,6 +1,5 @@ - x86_64 Penryn - - + + diff --git a/tests/cputestdata/x86-host+strict-force-extra-result.xml b/tests/cputestdata/x86-host+strict-force-extra-result.xml index 958d458fea..74b33279db 100644 --- a/tests/cputestdata/x86-host+strict-force-extra-result.xml +++ b/tests/cputestdata/x86-host+strict-force-extra-result.xml @@ -1,19 +1,18 @@ - - x86_64 + Penryn - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/tests/cputestdata/x86-host-Haswell-noTSX+Haswell,haswell-result.xml b/tests/cputestdata/x86-host-Haswell-noTSX+Haswell,haswell-result.xml index dfdca1370a..2dbe06c314 100644 --- a/tests/cputestdata/x86-host-Haswell-noTSX+Haswell,haswell-result.xml +++ b/tests/cputestdata/x86-host-Haswell-noTSX+Haswell,haswell-result.xml @@ -1,6 +1,6 @@ - x86_64 Haswell - + + diff --git a/tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX,haswell-result.xml b/tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX,haswell-result.xml index dfdca1370a..5902f6c76f 100644 --- a/tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX,haswell-result.xml +++ b/tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX,haswell-result.xml @@ -1,6 +1,7 @@ - x86_64 Haswell + Intel + diff --git a/tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX-result.xml b/tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX-result.xml index f5a67fb6b1..3b74089647 100644 --- a/tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX-result.xml +++ b/tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX-result.xml @@ -1,4 +1,4 @@ - x86_64 Haswell-noTSX + diff --git a/tests/cputestdata/x86-host-better+pentium3-result.xml b/tests/cputestdata/x86-host-better+pentium3-result.xml index a37b36890d..12336daf90 100644 --- a/tests/cputestdata/x86-host-better+pentium3-result.xml +++ b/tests/cputestdata/x86-host-better+pentium3-result.xml @@ -1,18 +1,18 @@ - x86_64 Nehalem - - - - - - - - - - - - - + Intel + + + + + + + + + + + + + diff --git a/tests/cputestdata/x86-host-worse+guest-result.xml b/tests/cputestdata/x86-host-worse+guest-result.xml index 6b9c74add4..2edc8756c4 100644 --- a/tests/cputestdata/x86-host-worse+guest-result.xml +++ b/tests/cputestdata/x86-host-worse+guest-result.xml @@ -1,9 +1,17 @@ - x86_64 Penryn - - - - + + + + + + + + + + + + +