2 * cputest.c: Test the libvirtd internal CPU APIs
4 * Copyright (C) 2010-2014 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see
18 * <http://www.gnu.org/licenses/>.
25 #include <sys/types.h>
31 #include "virbuffer.h"
32 #include "testutils.h"
35 #include "cpu/cpu_x86.h"
38 # include "testutilsqemu.h"
39 # include "qemumonitortestutils.h"
40 # define LIBVIRT_QEMU_CAPSPRIV_H_ALLOW
41 # include "qemu/qemu_capspriv.h"
44 #define VIR_FROM_THIS VIR_FROM_CPU
46 enum cpuTestBoolWithError
{
57 virDomainCapsCPUModels
*models
;
58 const char *modelsName
;
66 static virQEMUDriver driver
;
71 cpuTestLoadXML(virArch arch
, const char *name
)
73 g_autofree
char *xml
= NULL
;
74 g_autoptr(xmlDoc
) doc
= NULL
;
75 g_autoptr(xmlXPathContext
) ctxt
= NULL
;
76 virCPUDef
*cpu
= NULL
;
78 xml
= g_strdup_printf("%s/cputestdata/%s-%s.xml", abs_srcdir
,
79 virArchToString(arch
), name
);
81 if (!(doc
= virXMLParseFileCtxt(xml
, &ctxt
)))
84 virCPUDefParseXML(ctxt
, NULL
, VIR_CPU_TYPE_AUTO
, &cpu
, false);
91 cpuTestLoadMultiXML(virArch arch
,
95 g_autofree
char *xml
= NULL
;
96 g_autoptr(xmlDoc
) doc
= NULL
;
97 g_autoptr(xmlXPathContext
) ctxt
= NULL
;
98 g_autofree xmlNodePtr
*nodes
= NULL
;
99 virCPUDef
**cpus
= NULL
;
103 xml
= g_strdup_printf("%s/cputestdata/%s-%s.xml", abs_srcdir
,
104 virArchToString(arch
), name
);
106 if (!(doc
= virXMLParseFileCtxt(xml
, &ctxt
)))
109 n
= virXPathNodeSet("/cpuTest/cpu", ctxt
, &nodes
);
111 fprintf(stderr
, "\nNo /cpuTest/cpu elements found in %s\n", xml
);
115 cpus
= g_new0(virCPUDef
*, n
);
117 for (i
= 0; i
< n
; i
++) {
118 ctxt
->node
= nodes
[i
];
119 if (virCPUDefParseXML(ctxt
, NULL
, VIR_CPU_TYPE_HOST
, &cpus
[i
],
129 for (i
= 0; i
< n
; i
++)
130 virCPUDefFree(cpus
[i
]);
137 cpuTestCompareXML(virArch arch
,
141 g_autofree
char *xml
= NULL
;
142 g_autofree
char *actual
= NULL
;
144 xml
= g_strdup_printf("%s/cputestdata/%s-%s.xml", abs_srcdir
,
145 virArchToString(arch
), name
);
147 if (!(actual
= virCPUDefFormat(cpu
, NULL
)))
150 if (virTestCompareToFile(actual
, xml
) < 0)
158 cpuTestCompResStr(virCPUCompareResult result
)
161 case VIR_CPU_COMPARE_ERROR
: return "ERROR";
162 case VIR_CPU_COMPARE_INCOMPATIBLE
: return "INCOMPATIBLE";
163 case VIR_CPU_COMPARE_IDENTICAL
: return "IDENTICAL";
164 case VIR_CPU_COMPARE_SUPERSET
: return "SUPERSET";
165 case VIR_CPU_COMPARE_LAST
: break;
173 cpuTestBoolWithErrorStr(enum cpuTestBoolWithError result
)
176 case FAIL
: return "FAIL";
177 case NO
: return "NO";
178 case YES
: return "YES";
186 cpuTestCompare(const void *arg
)
188 const struct data
*data
= arg
;
189 g_autoptr(virCPUDef
) host
= NULL
;
190 g_autoptr(virCPUDef
) cpu
= NULL
;
191 virCPUCompareResult result
;
193 if (!(host
= cpuTestLoadXML(data
->arch
, data
->host
)) ||
194 !(cpu
= cpuTestLoadXML(data
->arch
, data
->name
)))
197 result
= virCPUCompare(host
->arch
, host
, cpu
, false);
198 if (data
->result
== VIR_CPU_COMPARE_ERROR
)
201 if (data
->result
!= result
) {
202 VIR_TEST_VERBOSE("\nExpected result %s, got %s",
203 cpuTestCompResStr(data
->result
),
204 cpuTestCompResStr(result
));
205 /* Pad to line up with test name ... in virTestRun */
206 VIR_TEST_VERBOSE("%74s", "... ");
215 cpuTestGuestCPU(const void *arg
)
217 const struct data
*data
= arg
;
219 g_autoptr(virCPUDef
) host
= NULL
;
220 g_autoptr(virCPUDef
) cpu
= NULL
;
221 virCPUCompareResult cmpResult
;
222 g_auto(virBuffer
) buf
= VIR_BUFFER_INITIALIZER
;
223 g_autofree
char *result
= NULL
;
225 if (!(host
= cpuTestLoadXML(data
->arch
, data
->host
)) ||
226 !(cpu
= cpuTestLoadXML(data
->arch
, data
->name
)))
229 if (virCPUConvertLegacy(host
->arch
, cpu
) < 0)
232 cmpResult
= virCPUCompare(host
->arch
, host
, cpu
, false);
233 if (cmpResult
== VIR_CPU_COMPARE_ERROR
||
234 cmpResult
== VIR_CPU_COMPARE_INCOMPATIBLE
) {
239 if (virCPUUpdate(host
->arch
, cpu
, host
, VIR_CPU_FEATURE_DISABLE
) < 0 ||
240 virCPUTranslate(host
->arch
, cpu
, data
->models
) < 0) {
245 virBufferAsprintf(&buf
, "%s+%s", data
->host
, data
->name
);
246 if (data
->modelsName
)
247 virBufferAsprintf(&buf
, ",%s", data
->modelsName
);
248 virBufferAddLit(&buf
, "-result");
250 result
= virBufferContentAndReset(&buf
);
252 if (cpuTestCompareXML(data
->arch
, cpu
, result
) < 0)
258 if (ret
== data
->result
) {
259 /* We got the result we expected, whether it was
260 * a success or a failure */
264 VIR_TEST_VERBOSE("\nExpected result %d, got %d",
266 /* Pad to line up with test name ... in virTestRun */
267 VIR_TEST_VERBOSE("%74s", "... ");
276 cpuTestBaseline(const void *arg
)
278 const struct data
*data
= arg
;
280 virCPUDef
**cpus
= NULL
;
281 virCPUDef
*baseline
= NULL
;
282 unsigned int ncpus
= 0;
283 g_autofree
char *result
= NULL
;
287 if (!(cpus
= cpuTestLoadMultiXML(data
->arch
, data
->name
, &ncpus
)))
290 baseline
= virCPUBaseline(data
->arch
, cpus
, ncpus
, NULL
, NULL
,
291 !!(data
->flags
& VIR_CONNECT_BASELINE_CPU_MIGRATABLE
));
294 (data
->flags
& VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES
) &&
295 virCPUExpandFeatures(data
->arch
, baseline
) < 0) {
296 g_clear_pointer(&baseline
, virCPUDefFree
);
299 if (data
->result
< 0) {
304 VIR_TEST_VERBOSE("\n%-70s... ",
305 "virCPUBaseline was expected to fail but it succeeded");
312 if (data
->flags
& VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES
)
314 else if (data
->flags
& VIR_CONNECT_BASELINE_CPU_MIGRATABLE
)
315 suffix
= "migratable";
318 result
= g_strdup_printf("%s-%s", data
->name
, suffix
);
320 if (cpuTestCompareXML(data
->arch
, baseline
, result
) < 0)
323 for (i
= 0; i
< ncpus
; i
++) {
324 virCPUCompareResult cmp
;
326 cmp
= virCPUCompare(cpus
[i
]->arch
, cpus
[i
], baseline
, false);
327 if (cmp
!= VIR_CPU_COMPARE_SUPERSET
&&
328 cmp
!= VIR_CPU_COMPARE_IDENTICAL
) {
329 VIR_TEST_VERBOSE("\nbaseline CPU is incompatible with CPU %zu",
331 VIR_TEST_VERBOSE("%74s", "... ");
341 for (i
= 0; i
< ncpus
; i
++)
342 virCPUDefFree(cpus
[i
]);
345 virCPUDefFree(baseline
);
351 cpuTestUpdate(const void *arg
)
353 const struct data
*data
= arg
;
354 g_autoptr(virCPUDef
) host
= NULL
;
355 g_autoptr(virCPUDef
) migHost
= NULL
;
356 g_autoptr(virCPUDef
) cpu
= NULL
;
357 g_autofree
char *result
= NULL
;
359 if (!(host
= cpuTestLoadXML(data
->arch
, data
->host
)) ||
360 !(cpu
= cpuTestLoadXML(data
->arch
, data
->name
)))
363 if (!(migHost
= virCPUCopyMigratable(data
->arch
, host
)))
366 if (virCPUUpdate(host
->arch
, cpu
, migHost
, VIR_CPU_FEATURE_DISABLE
) < 0)
369 result
= g_strdup_printf("%s+%s", data
->host
, data
->name
);
371 return cpuTestCompareXML(data
->arch
, cpu
, result
);
376 cpuTestHasFeature(const void *arg
)
378 const struct data
*data
= arg
;
379 g_autoptr(virCPUDef
) host
= NULL
;
380 g_autoptr(virCPUData
) hostData
= NULL
;
383 if (!(host
= cpuTestLoadXML(data
->arch
, data
->host
)))
386 if (cpuEncode(host
->arch
, host
, NULL
, &hostData
,
387 NULL
, NULL
, NULL
, NULL
) < 0)
390 result
= virCPUCheckFeature(host
->arch
, host
, data
->name
);
392 if (data
->result
== result
)
393 result
= virCPUDataCheckFeature(hostData
, data
->name
);
395 if (data
->result
== -1)
398 if (data
->result
!= result
) {
399 VIR_TEST_VERBOSE("\nExpected result %s, got %s",
400 cpuTestBoolWithErrorStr(data
->result
),
401 cpuTestBoolWithErrorStr(result
));
402 /* Pad to line up with test name ... in virTestRun */
403 VIR_TEST_VERBOSE("%74s", "... ");
412 /* No JSON data from QEMU. */
414 /* Only a reply from query-cpu-model-expansion QMP command. */
416 /* Replies from both query-cpu-model-expansion and query-cpu-definitions
420 /* Same as JSON_MODELS, but the reply from query-cpu-definitions has to
421 * be parsed for providing the correct result. This happens when the
422 * CPU model detected by libvirt has non-empty unavailable-features array
423 * in query-cpu-definitions reply or when the CPU model detected from CPUID
424 * differs from the one we get from QEMU and we need to translate them for
425 * comparison. Such tests require QEMU driver to be enabled.
427 JSON_MODELS_REQUIRED
,
432 cpuTestMakeQEMUCaps(const struct data
*data
)
434 g_autoptr(virQEMUCaps
) qemuCaps
= NULL
;
435 g_autoptr(qemuMonitorTest
) testMon
= NULL
;
436 g_autoptr(qemuMonitorCPUModelInfo
) model
= NULL
;
437 g_autoptr(virCPUDef
) cpu
= NULL
;
438 bool fail_no_props
= true;
439 g_autofree
char *json
= NULL
;
441 json
= g_strdup_printf("%s/cputestdata/%s-cpuid-%s.json", abs_srcdir
,
442 virArchToString(data
->arch
), data
->host
);
444 if (!(testMon
= qemuMonitorTestNewFromFile(json
, driver
.xmlopt
, true)))
447 qemuMonitorTestAllowUnusedCommands(testMon
);
449 cpu
= virCPUDefNew();
451 cpu
->model
= g_strdup("host");
453 if (ARCH_IS_S390(data
->arch
))
454 fail_no_props
= false;
456 if (qemuMonitorGetCPUModelExpansion(qemuMonitorTestGetMonitor(testMon
),
457 QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC
,
458 cpu
, true, false, fail_no_props
, &model
) < 0)
461 qemuCaps
= virQEMUCapsNew();
463 virQEMUCapsSet(qemuCaps
, QEMU_CAPS_KVM
);
464 if (data
->flags
== JSON_MODELS
||
465 data
->flags
== JSON_MODELS_REQUIRED
)
466 virQEMUCapsSet(qemuCaps
, QEMU_CAPS_QUERY_CPU_DEFINITIONS
);
468 virQEMUCapsSetArch(qemuCaps
, data
->arch
);
469 virQEMUCapsSetCPUModelInfo(qemuCaps
, VIR_DOMAIN_VIRT_KVM
, model
);
472 if (virQEMUCapsProbeCPUDefinitionsTest(qemuCaps
,
473 qemuMonitorTestGetMonitor(testMon
)) < 0)
476 return g_steal_pointer(&qemuCaps
);
481 cpuTestGetCPUModels(const struct data
*data
,
482 virDomainCapsCPUModels
**models
)
484 g_autoptr(virQEMUCaps
) qemuCaps
= NULL
;
488 if (data
->flags
!= JSON_MODELS
&&
489 data
->flags
!= JSON_MODELS_REQUIRED
)
492 if (!(qemuCaps
= cpuTestMakeQEMUCaps(data
)))
495 *models
= virQEMUCapsGetCPUModels(qemuCaps
, VIR_DOMAIN_VIRT_KVM
, NULL
, NULL
);
500 #else /* if WITH_QEMU */
503 cpuTestGetCPUModels(const struct data
*data
,
504 virDomainCapsCPUModels
**models
)
508 if (data
->flags
== JSON_MODELS_REQUIRED
)
518 cpuTestCPUID(bool guest
, const void *arg
)
520 const struct data
*data
= arg
;
521 g_autoptr(virCPUData
) hostData
= NULL
;
522 g_autofree
char *hostFile
= NULL
;
523 g_autofree
char *host
= NULL
;
524 g_autoptr(virCPUDef
) cpu
= NULL
;
525 g_autofree
char *result
= NULL
;
526 g_autoptr(virDomainCapsCPUModels
) models
= NULL
;
528 hostFile
= g_strdup_printf("%s/cputestdata/%s-cpuid-%s.xml", abs_srcdir
,
529 virArchToString(data
->arch
), data
->host
);
531 if (virTestLoadFile(hostFile
, &host
) < 0 ||
532 !(hostData
= virCPUDataParse(host
)))
535 cpu
= virCPUDefNew();
536 cpu
->arch
= hostData
->arch
;
538 cpu
->type
= VIR_CPU_TYPE_GUEST
;
539 cpu
->match
= VIR_CPU_MATCH_EXACT
;
540 cpu
->fallback
= VIR_CPU_FALLBACK_FORBID
;
542 cpu
->type
= VIR_CPU_TYPE_HOST
;
548 rc
= cpuTestGetCPUModels(data
, &models
);
553 if (cpuDecode(cpu
, hostData
, models
) < 0)
556 result
= g_strdup_printf("cpuid-%s-%s", data
->host
, guest
? "guest" : "host");
558 return cpuTestCompareXML(data
->arch
, cpu
, result
);
563 cpuTestCPUIDBaseline(const void *arg
)
565 const struct data
*data
= arg
;
567 virCPUDef
**cpus
= NULL
;
568 virCPUDef
*baseline
= NULL
;
569 g_autofree
char *result
= NULL
;
572 cpus
= g_new0(virCPUDef
*, data
->ncpus
);
573 for (i
= 0; i
< data
->ncpus
; i
++) {
574 g_autofree
char *name
= NULL
;
576 name
= g_strdup_printf("cpuid-%s-json", data
->cpus
[i
]);
577 if (!(cpus
[i
] = cpuTestLoadXML(data
->arch
, name
)))
581 baseline
= virCPUBaseline(data
->arch
, cpus
, data
->ncpus
, NULL
, NULL
, false);
585 result
= g_strdup_printf("cpuid-baseline-%s", data
->name
);
587 if (cpuTestCompareXML(data
->arch
, baseline
, result
) < 0)
590 for (i
= 0; i
< data
->ncpus
; i
++) {
591 virCPUCompareResult cmp
;
593 cmp
= virCPUCompare(data
->arch
, cpus
[i
], baseline
, false);
594 if (cmp
!= VIR_CPU_COMPARE_SUPERSET
&&
595 cmp
!= VIR_CPU_COMPARE_IDENTICAL
) {
596 VIR_TEST_VERBOSE("\nbaseline CPU is incompatible with CPU %zu", i
);
597 VIR_TEST_VERBOSE("%74s", "... ");
607 for (i
= 0; i
< data
->ncpus
; i
++)
608 virCPUDefFree(cpus
[i
]);
611 virCPUDefFree(baseline
);
617 cpuTestHostCPUID(const void *arg
)
619 return cpuTestCPUID(false, arg
);
624 cpuTestGuestCPUID(const void *arg
)
626 return cpuTestCPUID(true, arg
);
631 cpuTestCompareSignature(const struct data
*data
,
632 virCPUData
*hostData
)
634 g_autofree
char *result
= NULL
;
635 g_autofree
char *sigStr
= NULL
;
636 unsigned long signature
;
639 unsigned int stepping
;
641 signature
= virCPUx86DataGetSignature(hostData
, &family
, &model
, &stepping
);
643 result
= g_strdup_printf("%s/cputestdata/%s-cpuid-%s.sig", abs_srcdir
,
644 virArchToString(data
->arch
), data
->host
);
646 sigStr
= g_strdup_printf("%1$06lx\n" "family: %2$3u (0x%2$02x)\n"
647 "model: %3$3u (0x%3$02x)\n" "stepping: %4$3u (0x%4$02x)\n",
648 signature
, family
, model
, stepping
);
650 return virTestCompareToFile(sigStr
, result
);
655 cpuTestCPUIDSignature(const void *arg
)
657 const struct data
*data
= arg
;
658 g_autoptr(virCPUData
) hostData
= NULL
;
659 g_autofree
char *hostFile
= NULL
;
660 g_autofree
char *host
= NULL
;
662 hostFile
= g_strdup_printf("%s/cputestdata/%s-cpuid-%s.xml", abs_srcdir
,
663 virArchToString(data
->arch
), data
->host
);
665 if (virTestLoadFile(hostFile
, &host
) < 0 ||
666 !(hostData
= virCPUDataParse(host
)))
669 return cpuTestCompareSignature(data
, hostData
);
674 cpuTestUpdateLiveCompare(virArch arch
,
681 if (virCPUExpandFeatures(arch
, actual
) < 0 ||
682 virCPUExpandFeatures(arch
, expected
) < 0)
685 if (STRNEQ(actual
->model
, expected
->model
)) {
686 VIR_TEST_VERBOSE("Actual CPU model '%s', expected '%s'",
687 actual
->model
, expected
->model
);
692 while (i
< actual
->nfeatures
|| j
< expected
->nfeatures
) {
693 virCPUFeatureDef
*featAct
= NULL
;
694 virCPUFeatureDef
*featExp
= NULL
;
697 if (i
< actual
->nfeatures
)
698 featAct
= actual
->features
+ i
;
700 if (j
< expected
->nfeatures
)
701 featExp
= expected
->features
+ j
;
704 * Act < Exp => cmp < 0 (missing entry in Exp)
705 * Act = Exp => cmp = 0
706 * Act > Exp => cmp > 0 (missing entry in Act)
708 * NULL > name for any name != NULL
710 if (featAct
&& featExp
)
711 cmp
= strcmp(featAct
->name
, featExp
->name
);
713 cmp
= featExp
? 1 : -1;
720 /* Possible combinations of cmp, featAct->policy, and featExp->policy:
722 * ---------------------------------
727 * ---------------------------------
728 * - dis X ok # ignoring extra disabled features
730 * ---------------------------------
735 featAct
->policy
== VIR_CPU_FEATURE_DISABLE
&&
736 featExp
->policy
== VIR_CPU_FEATURE_REQUIRE
) ||
738 featExp
->policy
== VIR_CPU_FEATURE_REQUIRE
)) {
739 VIR_TEST_VERBOSE("Actual CPU lacks feature '%s'",
746 featAct
->policy
== VIR_CPU_FEATURE_REQUIRE
&&
747 featExp
->policy
== VIR_CPU_FEATURE_DISABLE
) ||
748 (cmp
< 0 && featAct
&&
749 featAct
->policy
== VIR_CPU_FEATURE_REQUIRE
) ||
751 featExp
->policy
== VIR_CPU_FEATURE_DISABLE
)) {
752 VIR_TEST_VERBOSE("Actual CPU has extra feature '%s'",
753 cmp
<= 0 ? featAct
->name
: featExp
->name
);
763 cpuTestUpdateLive(const void *arg
)
765 const struct data
*data
= arg
;
766 g_autofree
char *cpuFile
= NULL
;
767 g_autoptr(virCPUDef
) cpu
= NULL
;
768 g_autofree
char *enabledFile
= NULL
;
769 g_autofree
char *enabled
= NULL
;
770 g_autoptr(virCPUData
) enabledData
= NULL
;
771 g_autofree
char *disabledFile
= NULL
;
772 g_autofree
char *disabled
= NULL
;
773 g_autoptr(virCPUData
) disabledData
= NULL
;
774 g_autofree
char *expectedFile
= NULL
;
775 g_autoptr(virCPUDef
) expected
= NULL
;
776 g_autoptr(virDomainCapsCPUModels
) hvModels
= NULL
;
777 g_autoptr(virDomainCapsCPUModels
) models
= NULL
;
779 cpuFile
= g_strdup_printf("cpuid-%s-guest", data
->host
);
780 if (!(cpu
= cpuTestLoadXML(data
->arch
, cpuFile
)))
783 enabledFile
= g_strdup_printf("%s/cputestdata/%s-cpuid-%s-enabled.xml",
784 abs_srcdir
, virArchToString(data
->arch
), data
->host
);
785 if (virTestLoadFile(enabledFile
, &enabled
) < 0 ||
786 !(enabledData
= virCPUDataParse(enabled
)))
789 disabledFile
= g_strdup_printf("%s/cputestdata/%s-cpuid-%s-disabled.xml",
790 abs_srcdir
, virArchToString(data
->arch
), data
->host
);
791 if (virTestLoadFile(disabledFile
, &disabled
) < 0 ||
792 !(disabledData
= virCPUDataParse(disabled
)))
795 expectedFile
= g_strdup_printf("cpuid-%s-json", data
->host
);
796 if (!(expected
= cpuTestLoadXML(data
->arch
, expectedFile
)))
799 /* In case the host CPU signature does not exactly match any CPU model in
800 * src/cpu_map, the CPU model we detect from CPUID may differ from the one
801 * we compute by asking QEMU. Since this test expands both CPU models and
802 * compares their features, we can try to translate the 'actual' CPU to
803 * use the CPU model from 'expected'.
805 if (STRNEQ(cpu
->model
, expected
->model
)) {
806 virDomainCapsCPUModel
*hvModel
;
807 char **blockers
= NULL
;
808 virDomainCapsCPUUsable usable
= VIR_DOMCAPS_CPU_USABLE_UNKNOWN
;
811 if (!(models
= virDomainCapsCPUModelsNew(0)))
814 rc
= cpuTestGetCPUModels(data
, &hvModels
);
818 hvModel
= virDomainCapsCPUModelsGet(hvModels
, expected
->model
);
821 blockers
= hvModel
->blockers
;
822 usable
= hvModel
->usable
;
825 virDomainCapsCPUModelsAdd(models
, expected
->model
,
826 usable
, blockers
, false,
827 expected
->vendor
, NULL
);
829 cpu
->fallback
= VIR_CPU_FALLBACK_ALLOW
;
830 ignore_value(virCPUTranslate(data
->arch
, cpu
, models
));
831 cpu
->fallback
= VIR_CPU_FALLBACK_FORBID
;
834 if (virCPUUpdateLive(data
->arch
, cpu
, enabledData
, disabledData
) < 0)
837 return cpuTestUpdateLiveCompare(data
->arch
, cpu
, expected
);
843 cpuTestJSONCPUID(const void *arg
)
845 const struct data
*data
= arg
;
846 g_autoptr(virQEMUCaps
) qemuCaps
= NULL
;
847 g_autoptr(virCPUDef
) cpu
= NULL
;
848 g_autofree
char *result
= NULL
;
850 result
= g_strdup_printf("cpuid-%s-json", data
->host
);
852 if (!(qemuCaps
= cpuTestMakeQEMUCaps(data
)))
855 cpu
= virCPUDefNew();
856 cpu
->arch
= data
->arch
;
857 cpu
->type
= VIR_CPU_TYPE_GUEST
;
858 cpu
->match
= VIR_CPU_MATCH_EXACT
;
859 cpu
->fallback
= VIR_CPU_FALLBACK_FORBID
;
861 if (virQEMUCapsInitCPUModel(qemuCaps
, VIR_DOMAIN_VIRT_KVM
, cpu
, false) != 0)
864 return cpuTestCompareXML(data
->arch
, cpu
, result
);
869 cpuTestJSONSignature(const void *arg
)
871 const struct data
*data
= arg
;
872 g_autoptr(virQEMUCaps
) qemuCaps
= NULL
;
873 g_autoptr(virCPUData
) hostData
= NULL
;
874 qemuMonitorCPUModelInfo
*modelInfo
;
876 if (!(qemuCaps
= cpuTestMakeQEMUCaps(data
)))
879 modelInfo
= virQEMUCapsGetCPUModelInfo(qemuCaps
, VIR_DOMAIN_VIRT_KVM
);
880 if (!(hostData
= virQEMUCapsGetCPUModelX86Data(qemuCaps
, modelInfo
, false)))
883 return cpuTestCompareSignature(data
, hostData
);
888 static const char *model486_list
[] = { "486", NULL
};
889 static const char *nomodel_list
[] = { "nomodel", NULL
};
890 static const char *models_list
[] = { "qemu64", "core2duo", "Nehalem", NULL
};
891 static const char *haswell_list
[] = { "SandyBridge", "Haswell", NULL
};
892 static const char *ppc_models_list
[] = { "POWER6", "POWER7", "POWER8", NULL
};
894 static virDomainCapsCPUModels
*
895 cpuTestInitModels(const char **list
)
897 virDomainCapsCPUModels
*cpus
;
900 if (!(cpus
= virDomainCapsCPUModelsNew(0)))
903 for (model
= list
; *model
; model
++) {
904 virDomainCapsCPUModelsAdd(cpus
, *model
,
905 VIR_DOMCAPS_CPU_USABLE_UNKNOWN
,
906 NULL
, false, NULL
, NULL
);
916 virDomainCapsCPUModels
*model486
= NULL
;
917 virDomainCapsCPUModels
*nomodel
= NULL
;
918 virDomainCapsCPUModels
*models
= NULL
;
919 virDomainCapsCPUModels
*haswell
= NULL
;
920 virDomainCapsCPUModels
*ppc_models
= NULL
;
924 if (qemuTestDriverInit(&driver
) < 0)
927 virEventRegisterDefaultImpl();
930 if (!(model486
= cpuTestInitModels(model486_list
)) ||
931 !(nomodel
= cpuTestInitModels(nomodel_list
)) ||
932 !(models
= cpuTestInitModels(models_list
)) ||
933 !(haswell
= cpuTestInitModels(haswell_list
)) ||
934 !(ppc_models
= cpuTestInitModels(ppc_models_list
))) {
939 #define DO_TEST(arch, api, name, host, cpu, cpus, ncpus, \
940 models, flags, result) \
942 struct data data = { \
943 arch, host, cpu, models, \
944 models == NULL ? NULL : #models, \
945 cpus, ncpus, flags, result \
947 g_autofree char *testLabel = NULL; \
949 testLabel = g_strdup_printf("%s(%s): %s", #api, \
950 virArchToString(arch), name); \
952 virTestRunLog(&ret, testLabel, api, &data); \
955 #define DO_TEST_COMPARE(arch, host, cpu, result) \
956 DO_TEST(arch, cpuTestCompare, \
957 host "/" cpu " (" #result ")", \
958 host, cpu, NULL, 0, NULL, 0, result)
960 #define DO_TEST_UPDATE_ONLY(arch, host, cpu) \
961 DO_TEST(arch, cpuTestUpdate, \
963 host, cpu, NULL, 0, NULL, 0, 0)
965 #define DO_TEST_UPDATE(arch, host, cpu, result) \
967 DO_TEST_UPDATE_ONLY(arch, host, cpu); \
968 DO_TEST_COMPARE(arch, host, host "+" cpu, result); \
971 #define DO_TEST_BASELINE(arch, name, flags, result) \
973 const char *suffix = ""; \
974 g_autofree char *label = NULL; \
975 if ((flags) & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) \
976 suffix = " (expanded)"; \
977 if ((flags) & VIR_CONNECT_BASELINE_CPU_MIGRATABLE) \
978 suffix = " (migratable)"; \
979 label = g_strdup_printf("%s%s", name, suffix); \
980 DO_TEST(arch, cpuTestBaseline, label, NULL, \
981 "baseline-" name, NULL, 0, NULL, flags, result); \
984 #define DO_TEST_HASFEATURE(arch, host, feature, result) \
985 DO_TEST(arch, cpuTestHasFeature, \
986 host "/" feature " (" #result ")", \
987 host, feature, NULL, 0, NULL, 0, result)
989 #define DO_TEST_GUESTCPU(arch, host, cpu, models, result) \
990 DO_TEST(arch, cpuTestGuestCPU, \
991 host "/" cpu " (" #models ")", \
992 host, cpu, NULL, 0, models, 0, result)
995 # define DO_TEST_JSON(arch, host, json) \
997 if (json != JSON_NONE) { \
998 DO_TEST(arch, cpuTestJSONCPUID, host, host, \
999 NULL, NULL, 0, NULL, json, 0); \
1000 DO_TEST(arch, cpuTestJSONSignature, host, host, \
1001 NULL, NULL, 0, NULL, 0, 0); \
1005 # define DO_TEST_JSON(arch, host, json)
1008 #define DO_TEST_CPUID(arch, host, json) \
1010 DO_TEST(arch, cpuTestHostCPUID, host, host, \
1011 NULL, NULL, 0, NULL, 0, 0); \
1012 DO_TEST(arch, cpuTestGuestCPUID, host, host, \
1013 NULL, NULL, 0, NULL, json, 0); \
1014 DO_TEST(arch, cpuTestCPUIDSignature, host, host, \
1015 NULL, NULL, 0, NULL, 0, 0); \
1016 DO_TEST_JSON(arch, host, json); \
1017 if (json != JSON_NONE) { \
1018 DO_TEST(arch, cpuTestUpdateLive, host, host, \
1019 NULL, NULL, 0, NULL, json, 0); \
1023 #define DO_TEST_CPUID_BASELINE(arch, label, cpu1, cpu2) \
1025 const char *cpus[] = {cpu1, cpu2}; \
1026 DO_TEST(arch, cpuTestCPUIDBaseline, \
1027 label " (" cpu1 ", " cpu2 ")", \
1028 NULL, label, cpus, 2, NULL, 0, 0); \
1031 /* host to host comparison */
1032 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "host", VIR_CPU_COMPARE_IDENTICAL
);
1033 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "host-better", VIR_CPU_COMPARE_INCOMPATIBLE
);
1034 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "host-worse", VIR_CPU_COMPARE_SUPERSET
);
1035 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "host-amd-fake", VIR_CPU_COMPARE_INCOMPATIBLE
);
1036 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "host-incomp-arch", VIR_CPU_COMPARE_INCOMPATIBLE
);
1037 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "host-no-vendor", VIR_CPU_COMPARE_IDENTICAL
);
1038 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host-no-vendor", "host", VIR_CPU_COMPARE_INCOMPATIBLE
);
1040 DO_TEST_COMPARE(VIR_ARCH_PPC64
, "host", "host", VIR_CPU_COMPARE_IDENTICAL
);
1041 DO_TEST_COMPARE(VIR_ARCH_PPC64
, "host", "host-better", VIR_CPU_COMPARE_INCOMPATIBLE
);
1042 DO_TEST_COMPARE(VIR_ARCH_PPC64
, "host", "host-worse", VIR_CPU_COMPARE_INCOMPATIBLE
);
1043 DO_TEST_COMPARE(VIR_ARCH_PPC64
, "host", "host-incomp-arch", VIR_CPU_COMPARE_INCOMPATIBLE
);
1044 DO_TEST_COMPARE(VIR_ARCH_PPC64
, "host", "host-no-vendor", VIR_CPU_COMPARE_IDENTICAL
);
1045 DO_TEST_COMPARE(VIR_ARCH_PPC64
, "host-no-vendor", "host", VIR_CPU_COMPARE_INCOMPATIBLE
);
1047 /* guest to host comparison */
1048 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "bogus-model", VIR_CPU_COMPARE_ERROR
);
1049 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "bogus-feature", VIR_CPU_COMPARE_ERROR
);
1050 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "min", VIR_CPU_COMPARE_SUPERSET
);
1051 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "pentium3", VIR_CPU_COMPARE_SUPERSET
);
1052 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "exact", VIR_CPU_COMPARE_SUPERSET
);
1053 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "exact-forbid", VIR_CPU_COMPARE_INCOMPATIBLE
);
1054 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "exact-forbid-extra", VIR_CPU_COMPARE_SUPERSET
);
1055 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "exact-disable", VIR_CPU_COMPARE_SUPERSET
);
1056 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "exact-disable2", VIR_CPU_COMPARE_SUPERSET
);
1057 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "exact-disable-extra", VIR_CPU_COMPARE_SUPERSET
);
1058 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "exact-require", VIR_CPU_COMPARE_SUPERSET
);
1059 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "exact-require-extra", VIR_CPU_COMPARE_INCOMPATIBLE
);
1060 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "exact-force", VIR_CPU_COMPARE_SUPERSET
);
1061 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "strict", VIR_CPU_COMPARE_INCOMPATIBLE
);
1062 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "strict-full", VIR_CPU_COMPARE_IDENTICAL
);
1063 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "strict-disable", VIR_CPU_COMPARE_IDENTICAL
);
1064 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "strict-force-extra", VIR_CPU_COMPARE_IDENTICAL
);
1065 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "guest", VIR_CPU_COMPARE_SUPERSET
);
1066 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host", "pentium3-amd", VIR_CPU_COMPARE_INCOMPATIBLE
);
1067 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host-amd", "pentium3-amd", VIR_CPU_COMPARE_SUPERSET
);
1068 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host-worse", "penryn-force", VIR_CPU_COMPARE_IDENTICAL
);
1069 DO_TEST_COMPARE(VIR_ARCH_X86_64
, "host-SandyBridge", "exact-force-Haswell", VIR_CPU_COMPARE_IDENTICAL
);
1071 DO_TEST_COMPARE(VIR_ARCH_PPC64
, "host", "guest-strict", VIR_CPU_COMPARE_IDENTICAL
);
1072 DO_TEST_COMPARE(VIR_ARCH_PPC64
, "host", "guest-exact", VIR_CPU_COMPARE_INCOMPATIBLE
);
1073 DO_TEST_COMPARE(VIR_ARCH_PPC64
, "host", "guest-legacy", VIR_CPU_COMPARE_IDENTICAL
);
1074 DO_TEST_COMPARE(VIR_ARCH_PPC64
, "host", "guest-legacy-incompatible", VIR_CPU_COMPARE_INCOMPATIBLE
);
1075 DO_TEST_COMPARE(VIR_ARCH_PPC64
, "host", "guest-legacy-bad", VIR_CPU_COMPARE_ERROR
);
1076 DO_TEST_COMPARE(VIR_ARCH_PPC64
, "host", "guest-compat-none", VIR_CPU_COMPARE_IDENTICAL
);
1077 DO_TEST_COMPARE(VIR_ARCH_PPC64
, "host", "guest-compat-valid", VIR_CPU_COMPARE_IDENTICAL
);
1078 DO_TEST_COMPARE(VIR_ARCH_PPC64
, "host", "guest-compat-bad", VIR_CPU_COMPARE_ERROR
);
1079 DO_TEST_COMPARE(VIR_ARCH_PPC64
, "host", "guest-compat-incompatible", VIR_CPU_COMPARE_INCOMPATIBLE
);
1081 /* guest updates for migration
1082 * automatically compares host CPU with the result */
1083 DO_TEST_UPDATE(VIR_ARCH_X86_64
, "host", "min", VIR_CPU_COMPARE_IDENTICAL
);
1084 DO_TEST_UPDATE(VIR_ARCH_X86_64
, "host", "pentium3", VIR_CPU_COMPARE_IDENTICAL
);
1085 DO_TEST_UPDATE(VIR_ARCH_X86_64
, "host", "guest", VIR_CPU_COMPARE_SUPERSET
);
1086 DO_TEST_UPDATE(VIR_ARCH_X86_64
, "host", "host-model", VIR_CPU_COMPARE_IDENTICAL
);
1087 DO_TEST_UPDATE(VIR_ARCH_X86_64
, "host", "host-model-nofallback", VIR_CPU_COMPARE_IDENTICAL
);
1088 DO_TEST_UPDATE(VIR_ARCH_X86_64
, "host-invtsc", "host-model", VIR_CPU_COMPARE_SUPERSET
);
1089 DO_TEST_UPDATE_ONLY(VIR_ARCH_X86_64
, "host", "host-passthrough");
1090 DO_TEST_UPDATE_ONLY(VIR_ARCH_X86_64
, "host", "host-passthrough-features");
1092 DO_TEST_UPDATE(VIR_ARCH_PPC64
, "host", "guest", VIR_CPU_COMPARE_IDENTICAL
);
1093 DO_TEST_UPDATE(VIR_ARCH_PPC64
, "host", "guest-nofallback", VIR_CPU_COMPARE_INCOMPATIBLE
);
1094 DO_TEST_UPDATE(VIR_ARCH_PPC64
, "host", "guest-legacy", VIR_CPU_COMPARE_IDENTICAL
);
1095 DO_TEST_UPDATE(VIR_ARCH_PPC64
, "host", "guest-legacy-incompatible", VIR_CPU_COMPARE_INCOMPATIBLE
);
1096 DO_TEST_UPDATE(VIR_ARCH_PPC64
, "host", "guest-legacy-bad", VIR_CPU_COMPARE_ERROR
);
1097 DO_TEST_UPDATE(VIR_ARCH_PPC64
, "host", "guest-compat-none", VIR_CPU_COMPARE_IDENTICAL
);
1098 DO_TEST_UPDATE(VIR_ARCH_PPC64
, "host", "guest-compat-valid", VIR_CPU_COMPARE_IDENTICAL
);
1099 DO_TEST_UPDATE(VIR_ARCH_PPC64
, "host", "guest-compat-bad", VIR_CPU_COMPARE_ERROR
);
1100 DO_TEST_UPDATE(VIR_ARCH_PPC64
, "host", "guest-compat-incompatible", VIR_CPU_COMPARE_INCOMPATIBLE
);
1102 /* computing baseline CPUs */
1103 DO_TEST_BASELINE(VIR_ARCH_X86_64
, "incompatible-vendors", 0, -1);
1104 DO_TEST_BASELINE(VIR_ARCH_X86_64
, "no-vendor", 0, 0);
1105 DO_TEST_BASELINE(VIR_ARCH_X86_64
, "some-vendors", 0, 0);
1106 DO_TEST_BASELINE(VIR_ARCH_X86_64
, "simple", 0, 0);
1107 DO_TEST_BASELINE(VIR_ARCH_X86_64
, "simple", VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES
, 0);
1108 DO_TEST_BASELINE(VIR_ARCH_X86_64
, "features", 0, 0);
1109 DO_TEST_BASELINE(VIR_ARCH_X86_64
, "features", VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES
, 0);
1110 DO_TEST_BASELINE(VIR_ARCH_X86_64
, "Westmere+Nehalem", 0, 0);
1111 DO_TEST_BASELINE(VIR_ARCH_X86_64
, "Westmere+Nehalem", VIR_CONNECT_BASELINE_CPU_MIGRATABLE
, 0);
1113 DO_TEST_BASELINE(VIR_ARCH_PPC64
, "incompatible-vendors", 0, -1);
1114 DO_TEST_BASELINE(VIR_ARCH_PPC64
, "no-vendor", 0, 0);
1115 DO_TEST_BASELINE(VIR_ARCH_PPC64
, "incompatible-models", 0, -1);
1116 DO_TEST_BASELINE(VIR_ARCH_PPC64
, "same-model", 0, 0);
1117 DO_TEST_BASELINE(VIR_ARCH_PPC64
, "legacy", 0, -1);
1120 DO_TEST_HASFEATURE(VIR_ARCH_X86_64
, "host", "vmx", YES
);
1121 DO_TEST_HASFEATURE(VIR_ARCH_X86_64
, "host", "lm", YES
);
1122 DO_TEST_HASFEATURE(VIR_ARCH_X86_64
, "host", "sse4.1", YES
);
1123 DO_TEST_HASFEATURE(VIR_ARCH_X86_64
, "host", "3dnowext", NO
);
1124 DO_TEST_HASFEATURE(VIR_ARCH_X86_64
, "host", "skinit", NO
);
1125 DO_TEST_HASFEATURE(VIR_ARCH_X86_64
, "host", "foo", FAIL
);
1127 /* computing guest data and decoding the data into a guest CPU XML */
1128 DO_TEST_GUESTCPU(VIR_ARCH_X86_64
, "host", "guest", NULL
, 0);
1129 DO_TEST_GUESTCPU(VIR_ARCH_X86_64
, "host-better", "pentium3", NULL
, 0);
1130 DO_TEST_GUESTCPU(VIR_ARCH_X86_64
, "host-worse", "guest", NULL
, 0);
1131 DO_TEST_GUESTCPU(VIR_ARCH_X86_64
, "host", "strict-force-extra", NULL
, 0);
1132 DO_TEST_GUESTCPU(VIR_ARCH_X86_64
, "host", "penryn-force", NULL
, 0);
1133 DO_TEST_GUESTCPU(VIR_ARCH_X86_64
, "host", "guest", model486
, 0);
1134 DO_TEST_GUESTCPU(VIR_ARCH_X86_64
, "host", "guest", models
, 0);
1135 DO_TEST_GUESTCPU(VIR_ARCH_X86_64
, "host", "guest", nomodel
, -1);
1136 DO_TEST_GUESTCPU(VIR_ARCH_X86_64
, "host", "guest-nofallback", models
, -1);
1137 DO_TEST_GUESTCPU(VIR_ARCH_X86_64
, "host", "host+host-model", models
, 0);
1138 DO_TEST_GUESTCPU(VIR_ARCH_X86_64
, "host", "host+host-model-nofallback", models
, -1);
1139 DO_TEST_GUESTCPU(VIR_ARCH_X86_64
, "host-Haswell-noTSX", "Haswell", haswell
, 0);
1140 DO_TEST_GUESTCPU(VIR_ARCH_X86_64
, "host-Haswell-noTSX", "Haswell-noTSX", haswell
, 0);
1141 DO_TEST_GUESTCPU(VIR_ARCH_X86_64
, "host-Haswell-noTSX", "Haswell-noTSX-nofallback", haswell
, -1);
1142 DO_TEST_GUESTCPU(VIR_ARCH_X86_64
, "host-Haswell-noTSX", "Haswell-noTSX", NULL
, 0);
1144 DO_TEST_GUESTCPU(VIR_ARCH_PPC64
, "host", "guest", ppc_models
, 0);
1145 DO_TEST_GUESTCPU(VIR_ARCH_PPC64
, "host", "guest-nofallback", ppc_models
, -1);
1146 DO_TEST_GUESTCPU(VIR_ARCH_PPC64
, "host", "guest-legacy", ppc_models
, 0);
1147 DO_TEST_GUESTCPU(VIR_ARCH_PPC64
, "host", "guest-legacy-incompatible", ppc_models
, -1);
1148 DO_TEST_GUESTCPU(VIR_ARCH_PPC64
, "host", "guest-legacy-bad", ppc_models
, -1);
1150 DO_TEST_CPUID(VIR_ARCH_X86_64
, "A10-5800K", JSON_HOST
);
1151 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Atom-D510", JSON_NONE
);
1152 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Atom-N450", JSON_NONE
);
1153 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Atom-P5362", JSON_MODELS_REQUIRED
);
1154 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i5-650", JSON_MODELS_REQUIRED
);
1155 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i5-2500", JSON_HOST
);
1156 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i5-2540M", JSON_MODELS
);
1157 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i5-4670T", JSON_HOST
);
1158 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i5-6600", JSON_HOST
);
1159 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i7-2600", JSON_HOST
);
1160 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i7-2600-xsaveopt", JSON_MODELS_REQUIRED
);
1161 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i7-3520M", JSON_NONE
);
1162 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i7-3740QM", JSON_HOST
);
1163 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i7-3770", JSON_HOST
);
1164 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i7-4600U", JSON_HOST
);
1165 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i7-4510U", JSON_HOST
);
1166 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i7-5600U", JSON_HOST
);
1167 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i7-5600U-arat", JSON_HOST
);
1168 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i7-5600U-ibrs", JSON_HOST
);
1169 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i7-7600U", JSON_MODELS
);
1170 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i7-7700", JSON_MODELS
);
1171 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i7-8550U", JSON_MODELS
);
1172 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core-i7-8700", JSON_MODELS
);
1173 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core2-E6850", JSON_HOST
);
1174 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Core2-Q9500", JSON_NONE
);
1175 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Hygon-C86-7185-32-core", JSON_HOST
);
1176 DO_TEST_CPUID(VIR_ARCH_X86_64
, "EPYC-7601-32-Core", JSON_HOST
);
1177 DO_TEST_CPUID(VIR_ARCH_X86_64
, "EPYC-7601-32-Core-ibpb", JSON_MODELS_REQUIRED
);
1178 DO_TEST_CPUID(VIR_ARCH_X86_64
, "EPYC-7502-32-Core", JSON_MODELS
);
1179 DO_TEST_CPUID(VIR_ARCH_X86_64
, "FX-8150", JSON_NONE
);
1180 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Opteron-1352", JSON_NONE
);
1181 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Opteron-2350", JSON_HOST
);
1182 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Opteron-6234", JSON_HOST
);
1183 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Opteron-6282", JSON_NONE
);
1184 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Pentium-P6100", JSON_NONE
);
1185 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Phenom-B95", JSON_HOST
);
1186 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Ryzen-7-1800X-Eight-Core", JSON_HOST
);
1187 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Ryzen-9-3900X-12-Core", JSON_MODELS
);
1188 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-5110", JSON_NONE
);
1189 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-E3-1225-v5", JSON_MODELS
);
1190 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-E3-1245-v5", JSON_MODELS
);
1191 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-E5-2609-v3", JSON_MODELS
);
1192 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-E5-2623-v4", JSON_MODELS
);
1193 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-E5-2630-v3", JSON_HOST
);
1194 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-E5-2630-v4", JSON_MODELS
);
1195 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-E5-2650", JSON_MODELS
);
1196 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-E5-2650-v3", JSON_HOST
);
1197 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-E5-2650-v4", JSON_MODELS
);
1198 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-E7-4820", JSON_HOST
);
1199 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-E7-4830", JSON_MODELS_REQUIRED
);
1200 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-E7-8890-v3", JSON_MODELS
);
1201 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-E7540", JSON_MODELS
);
1202 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-Gold-5115", JSON_MODELS
);
1203 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-Gold-6130", JSON_MODELS
);
1204 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-Gold-6148", JSON_HOST
);
1205 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-Platinum-8268", JSON_HOST
);
1206 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-Platinum-9242", JSON_MODELS
);
1207 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-W3520", JSON_HOST
);
1208 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Xeon-X5460", JSON_NONE
);
1209 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Ice-Lake-Server", JSON_MODELS
);
1210 DO_TEST_CPUID(VIR_ARCH_X86_64
, "Cooperlake", JSON_MODELS
);
1212 DO_TEST_CPUID_BASELINE(VIR_ARCH_X86_64
, "Ryzen+Rome",
1213 "Ryzen-7-1800X-Eight-Core", "Ryzen-9-3900X-12-Core");
1214 DO_TEST_CPUID_BASELINE(VIR_ARCH_X86_64
, "EPYC+Rome",
1215 "EPYC-7601-32-Core", "EPYC-7502-32-Core");
1216 DO_TEST_CPUID_BASELINE(VIR_ARCH_X86_64
, "Haswell-noTSX-IBRS+Skylake",
1217 "Xeon-E5-2609-v3", "Xeon-Gold-6148");
1218 DO_TEST_CPUID_BASELINE(VIR_ARCH_X86_64
, "Haswell-noTSX-IBRS+Skylake-IBRS",
1219 "Xeon-E5-2609-v3", "Xeon-Gold-6130");
1220 DO_TEST_CPUID_BASELINE(VIR_ARCH_X86_64
, "Broadwell-IBRS+Cascadelake",
1221 "Xeon-E5-2623-v4", "Xeon-Platinum-8268");
1222 DO_TEST_CPUID_BASELINE(VIR_ARCH_X86_64
, "Cascadelake+Skylake-IBRS",
1223 "Xeon-Platinum-8268", "Xeon-Gold-6130");
1224 DO_TEST_CPUID_BASELINE(VIR_ARCH_X86_64
, "Cascadelake+Skylake",
1225 "Xeon-Platinum-9242", "Xeon-Gold-6148");
1226 DO_TEST_CPUID_BASELINE(VIR_ARCH_X86_64
, "Cascadelake+Icelake",
1227 "Xeon-Platinum-9242", "Ice-Lake-Server");
1228 DO_TEST_CPUID_BASELINE(VIR_ARCH_X86_64
, "Cooperlake+Icelake",
1229 "Cooperlake", "Ice-Lake-Server");
1230 DO_TEST_CPUID_BASELINE(VIR_ARCH_X86_64
, "Cooperlake+Cascadelake",
1231 "Cooperlake", "Xeon-Platinum-9242");
1232 DO_TEST_CPUID_BASELINE(VIR_ARCH_X86_64
, "Skylake-Client+Server",
1233 "Core-i5-6600", "Xeon-Gold-6148");
1234 DO_TEST_CPUID_BASELINE(VIR_ARCH_X86_64
, "Haswell-noTSX-IBRS+Broadwell",
1235 "Xeon-E5-2609-v3", "Xeon-E5-2650-v4");
1236 DO_TEST_CPUID_BASELINE(VIR_ARCH_X86_64
, "Haswell+Skylake",
1237 "Xeon-E7-8890-v3", "Xeon-Gold-5115");
1240 qemuTestDriverFree(&driver
);
1243 virObjectUnref(model486
);
1244 virObjectUnref(nomodel
);
1245 virObjectUnref(models
);
1246 virObjectUnref(haswell
);
1247 virObjectUnref(ppc_models
);
1249 return ret
== 0 ? EXIT_SUCCESS
: EXIT_FAILURE
;
1252 VIR_TEST_MAIN(mymain
)