diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 18c7b0d3cb..d181cd5406 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -500,30 +500,40 @@
-
+
-
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
diff --git a/tests/cputest.c b/tests/cputest.c
index a5075768fc..a9c0fec3fc 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -122,8 +122,10 @@ cpuTestLoadMultiXML(const char *arch,
goto cleanup;
n = virXPathNodeSet("/cpuTest/cpu", ctxt, &nodes);
- if (n <= 0 || (VIR_ALLOC_N(cpus, n) < 0))
+ if (n <= 0 || (VIR_ALLOC_N(cpus, n) < 0)) {
+ fprintf(stderr, "\nNo /cpuTest/cpu elements found in %s\n", xml);
goto cleanup;
+ }
for (i = 0; i < n; i++) {
ctxt->node = nodes[i];
@@ -496,6 +498,7 @@ cpuTestRun(const char *name, const struct data *data)
static const char *model486[] = { "486" };
static const char *nomodel[] = { "nomodel" };
static const char *models[] = { "qemu64", "core2duo", "Nehalem" };
+static const char *haswell[] = { "SandyBridge", "Haswell" };
static const char *ppc_models[] = { "POWER7", "POWER7_v2.1", "POWER8_v1.0"};
static int
@@ -641,6 +644,14 @@ mymain(void)
DO_TEST_GUESTDATA("x86", "host", "host+host-model", models, "Penryn", 0);
DO_TEST_GUESTDATA("x86", "host", "host+host-model-nofallback",
models, "Penryn", -1);
+ DO_TEST_GUESTDATA("x86", "host-Haswell-noTSX", "Haswell",
+ haswell, "Haswell", 0);
+ DO_TEST_GUESTDATA("x86", "host-Haswell-noTSX", "Haswell-noTSX",
+ haswell, "Haswell-noTSX", 0);
+ DO_TEST_GUESTDATA("x86", "host-Haswell-noTSX", "Haswell-noTSX-nofallback",
+ haswell, "Haswell-noTSX", -1);
+ DO_TEST_GUESTDATA("x86", "host-Haswell-noTSX", "Haswell-noTSX",
+ NULL, "Haswell-noTSX", 0);
DO_TEST_GUESTDATA("ppc64", "host", "guest", ppc_models, NULL, 0);
DO_TEST_GUESTDATA("ppc64", "host", "guest-nofallback", ppc_models, "POWER7_v2.1", -1);
diff --git a/tests/cputestdata/x86-Haswell-noTSX-nofallback.xml b/tests/cputestdata/x86-Haswell-noTSX-nofallback.xml
new file mode 100644
index 0000000000..c23c3f3bd0
--- /dev/null
+++ b/tests/cputestdata/x86-Haswell-noTSX-nofallback.xml
@@ -0,0 +1,4 @@
+
+ Haswell-noTSX
+
+
diff --git a/tests/cputestdata/x86-Haswell-noTSX.xml b/tests/cputestdata/x86-Haswell-noTSX.xml
new file mode 100644
index 0000000000..3b74089647
--- /dev/null
+++ b/tests/cputestdata/x86-Haswell-noTSX.xml
@@ -0,0 +1,4 @@
+
+ Haswell-noTSX
+
+
diff --git a/tests/cputestdata/x86-Haswell.xml b/tests/cputestdata/x86-Haswell.xml
new file mode 100644
index 0000000000..630cb99942
--- /dev/null
+++ b/tests/cputestdata/x86-Haswell.xml
@@ -0,0 +1,6 @@
+
+ Haswell
+
+
+
+
diff --git a/tests/cputestdata/x86-baseline-7-result.xml b/tests/cputestdata/x86-baseline-7-result.xml
new file mode 100644
index 0000000000..2af549e77a
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-7-result.xml
@@ -0,0 +1,4 @@
+
+ Haswell-noTSX
+ Intel
+
diff --git a/tests/cputestdata/x86-baseline-7.xml b/tests/cputestdata/x86-baseline-7.xml
new file mode 100644
index 0000000000..b7e61b160c
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-7.xml
@@ -0,0 +1,24 @@
+
+
+ x86_64
+ SandyBridge
+ Intel
+
+
+
+
+
+
+
+
+
+
+
+
+
+ x86_64
+ Haswell-noTSX
+ Intel
+
+
+
diff --git a/tests/cputestdata/x86-baseline-8-result.xml b/tests/cputestdata/x86-baseline-8-result.xml
new file mode 100644
index 0000000000..88226b3dab
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-8-result.xml
@@ -0,0 +1,4 @@
+
+ Broadwell-noTSX
+ Intel
+
diff --git a/tests/cputestdata/x86-baseline-8.xml b/tests/cputestdata/x86-baseline-8.xml
new file mode 100644
index 0000000000..f1ee67d542
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-8.xml
@@ -0,0 +1,28 @@
+
+
+ x86_64
+ SandyBridge
+ Intel
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ x86_64
+ Broadwell-noTSX
+ Intel
+
+
+
diff --git a/tests/cputestdata/x86-host-Haswell-noTSX+Haswell,haswell,Haswell-result.xml b/tests/cputestdata/x86-host-Haswell-noTSX+Haswell,haswell,Haswell-result.xml
new file mode 100644
index 0000000000..087aa7d4c9
--- /dev/null
+++ b/tests/cputestdata/x86-host-Haswell-noTSX+Haswell,haswell,Haswell-result.xml
@@ -0,0 +1,6 @@
+
+ x86_64
+ Haswell
+
+
+
diff --git a/tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX,Haswell-noTSX-result.xml b/tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX,Haswell-noTSX-result.xml
new file mode 100644
index 0000000000..f5a67fb6b1
--- /dev/null
+++ b/tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX,Haswell-noTSX-result.xml
@@ -0,0 +1,4 @@
+
+ x86_64
+ Haswell-noTSX
+
diff --git a/tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX,haswell,Haswell-noTSX-result.xml b/tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX,haswell,Haswell-noTSX-result.xml
new file mode 100644
index 0000000000..087aa7d4c9
--- /dev/null
+++ b/tests/cputestdata/x86-host-Haswell-noTSX+Haswell-noTSX,haswell,Haswell-noTSX-result.xml
@@ -0,0 +1,6 @@
+
+ x86_64
+ Haswell
+
+
+
diff --git a/tests/cputestdata/x86-host-Haswell-noTSX.xml b/tests/cputestdata/x86-host-Haswell-noTSX.xml
new file mode 100644
index 0000000000..c0030858e4
--- /dev/null
+++ b/tests/cputestdata/x86-host-Haswell-noTSX.xml
@@ -0,0 +1,6 @@
+
+ x86_64
+ Haswell-noTSX
+ Intel
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell-noTSX.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell-noTSX.args
new file mode 100644
index 0000000000..d64cc83812
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell-noTSX.args
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-kvm -S -M pc -cpu Haswell-noTSX -m 214 -smp 6 \
+-nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -usb -net \
+none -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell-noTSX.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell-noTSX.xml
new file mode 100644
index 0000000000..9ef24cd521
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell-noTSX.xml
@@ -0,0 +1,21 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219100
+ 219100
+ 6
+
+ hvm
+
+
+
+ Haswell-noTSX
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-kvm
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args
new file mode 100644
index 0000000000..f9bea6215b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-kvm -S -M pc -cpu Haswell -m 214 -smp 6 \
+-nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -usb -net \
+none -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.xml
new file mode 100644
index 0000000000..3af49f979e
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.xml
@@ -0,0 +1,21 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219100
+ 219100
+ 6
+
+ hvm
+
+
+
+ Haswell
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-kvm
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell2.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell2.args
new file mode 100644
index 0000000000..a398ab8849
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell2.args
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-kvm -S -M pc -cpu Haswell,-rtm,-hle -m 214 -smp 6 \
+-nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -usb -net \
+none -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell2.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell2.xml
new file mode 100644
index 0000000000..0d4efa14ff
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell2.xml
@@ -0,0 +1,23 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219100
+ 219100
+ 6
+
+ hvm
+
+
+
+ Haswell
+
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-kvm
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args
new file mode 100644
index 0000000000..f9bea6215b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-kvm -S -M pc -cpu Haswell -m 214 -smp 6 \
+-nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -usb -net \
+none -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.xml
new file mode 100644
index 0000000000..00617ebd6f
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.xml
@@ -0,0 +1,23 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219100
+ 219100
+ 6
+
+ hvm
+
+
+
+ Haswell
+
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-kvm
+
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d63ad9fa5d..5539a842e4 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -466,6 +466,7 @@ testAddCPUModels(virQEMUCapsPtr caps, bool skipLegacy)
const char *newModels[] = {
"Opteron_G3", "Opteron_G2", "Opteron_G1",
"Nehalem", "Penryn", "Conroe",
+ "Haswell-noTSX", "Haswell",
};
const char *legacyModels[] = {
"n270", "athlon", "pentium3", "pentium2", "pentium",
@@ -1235,6 +1236,13 @@ mymain(void)
DO_TEST_FAILURE("cpu-qemu-host-passthrough",
QEMU_CAPS_KVM, QEMU_CAPS_CPU_HOST);
+ driver.caps->host.cpu = cpuHaswell;
+ DO_TEST("cpu-Haswell", QEMU_CAPS_KVM);
+ DO_TEST("cpu-Haswell2", QEMU_CAPS_KVM);
+ DO_TEST("cpu-Haswell3", QEMU_CAPS_KVM);
+ DO_TEST("cpu-Haswell-noTSX", QEMU_CAPS_KVM);
+ driver.caps->host.cpu = cpuDefault;
+
DO_TEST("memtune", QEMU_CAPS_NAME);
DO_TEST("memtune-unlimited", QEMU_CAPS_NAME);
DO_TEST("blkiotune", QEMU_CAPS_NAME);
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 7b26e50bde..e8140fe792 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -12,6 +12,91 @@
# define VIR_FROM_THIS VIR_FROM_QEMU
+virCPUDefPtr cpuDefault;
+virCPUDefPtr cpuHaswell;
+
+static virCPUFeatureDef cpuDefaultFeatures[] = {
+ { (char *) "lahf_lm", -1 },
+ { (char *) "xtpr", -1 },
+ { (char *) "cx16", -1 },
+ { (char *) "tm2", -1 },
+ { (char *) "est", -1 },
+ { (char *) "vmx", -1 },
+ { (char *) "ds_cpl", -1 },
+ { (char *) "pbe", -1 },
+ { (char *) "tm", -1 },
+ { (char *) "ht", -1 },
+ { (char *) "ss", -1 },
+ { (char *) "acpi", -1 },
+ { (char *) "ds", -1 }
+};
+static virCPUDef cpuDefaultData = {
+ VIR_CPU_TYPE_HOST, /* type */
+ 0, /* mode */
+ 0, /* match */
+ VIR_ARCH_X86_64, /* arch */
+ (char *) "core2duo", /* model */
+ NULL, /* vendor_id */
+ 0, /* fallback */
+ (char *) "Intel", /* vendor */
+ 1, /* sockets */
+ 2, /* cores */
+ 1, /* threads */
+ ARRAY_CARDINALITY(cpuDefaultFeatures), /* nfeatures */
+ ARRAY_CARDINALITY(cpuDefaultFeatures), /* nfeatures_max */
+ cpuDefaultFeatures, /* features */
+ 0, /* ncells */
+ 0, /* ncells_max */
+ NULL, /* cells */
+ 0, /* cells_cpus */
+};
+
+static virCPUFeatureDef cpuHaswellFeatures[] = {
+ { (char *) "lahf_lm", -1 },
+ { (char *) "invtsc", -1 },
+ { (char *) "abm", -1 },
+ { (char *) "pdpe1gb", -1 },
+ { (char *) "rdrand", -1 },
+ { (char *) "f16c", -1 },
+ { (char *) "osxsave", -1 },
+ { (char *) "pdcm", -1 },
+ { (char *) "xtpr", -1 },
+ { (char *) "tm2", -1 },
+ { (char *) "est", -1 },
+ { (char *) "smx", -1 },
+ { (char *) "vmx", -1 },
+ { (char *) "ds_cpl", -1 },
+ { (char *) "monitor", -1 },
+ { (char *) "dtes64", -1 },
+ { (char *) "pbe", -1 },
+ { (char *) "tm", -1 },
+ { (char *) "ht", -1 },
+ { (char *) "ss", -1 },
+ { (char *) "acpi", -1 },
+ { (char *) "ds", -1 },
+ { (char *) "vme", -1 },
+};
+static virCPUDef cpuHaswellData = {
+ VIR_CPU_TYPE_HOST, /* type */
+ 0, /* mode */
+ 0, /* match */
+ VIR_ARCH_X86_64, /* arch */
+ (char *) "Haswell", /* model */
+ NULL, /* vendor_id */
+ 0, /* fallback */
+ (char *) "Intel", /* vendor */
+ 1, /* sockets */
+ 2, /* cores */
+ 2, /* threads */
+ ARRAY_CARDINALITY(cpuHaswellFeatures), /* nfeatures */
+ ARRAY_CARDINALITY(cpuHaswellFeatures), /* nfeatures_max */
+ cpuHaswellFeatures, /* features */
+ 0, /* ncells */
+ 0, /* ncells_max */
+ NULL, /* cells */
+ 0, /* cells_cpus */
+};
+
static virCapsGuestMachinePtr *testQemuAllocMachines(int *nmachines)
{
virCapsGuestMachinePtr *machines;
@@ -212,44 +297,8 @@ virCapsPtr testQemuCapsInit(void)
static const char *const xen_machines[] = {
"xenner"
};
- static virCPUFeatureDef host_cpu_features[] = {
- { (char *) "lahf_lm", -1 },
- { (char *) "xtpr", -1 },
- { (char *) "cx16", -1 },
- { (char *) "tm2", -1 },
- { (char *) "est", -1 },
- { (char *) "vmx", -1 },
- { (char *) "ds_cpl", -1 },
- { (char *) "pbe", -1 },
- { (char *) "tm", -1 },
- { (char *) "ht", -1 },
- { (char *) "ss", -1 },
- { (char *) "acpi", -1 },
- { (char *) "ds", -1 }
- };
- static virCPUDef host_cpu = {
- VIR_CPU_TYPE_HOST, /* type */
- 0, /* mode */
- 0, /* match */
- VIR_ARCH_X86_64, /* arch */
- (char *) "core2duo", /* model */
- NULL, /* vendor_id */
- 0, /* fallback */
- (char *) "Intel", /* vendor */
- 1, /* sockets */
- 2, /* cores */
- 1, /* threads */
- ARRAY_CARDINALITY(host_cpu_features), /* nfeatures */
- ARRAY_CARDINALITY(host_cpu_features), /* nfeatures_max */
- host_cpu_features, /* features */
- 0, /* ncells */
- 0, /* ncells_max */
- NULL, /* cells */
- 0, /* cells_cpus */
- };
- if ((caps = virCapabilitiesNew(host_cpu.arch,
- false, false)) == NULL)
+ if (!(caps = virCapabilitiesNew(VIR_ARCH_X86_64, false, false)))
return NULL;
/* Add dummy 'none' security_driver. This is equal to setting
@@ -262,8 +311,13 @@ virCapsPtr testQemuCapsInit(void)
VIR_STRDUP(caps->host.secModels[0].doi, "0") < 0)
goto cleanup;
- if ((caps->host.cpu = virCPUDefCopy(&host_cpu)) == NULL ||
- (machines = testQemuAllocMachines(&nmachines)) == NULL)
+ if (!(cpuDefault = virCPUDefCopy(&cpuDefaultData)) ||
+ !(cpuHaswell = virCPUDefCopy(&cpuHaswellData)))
+ goto cleanup;
+
+ caps->host.cpu = cpuDefault;
+
+ if ((machines = testQemuAllocMachines(&nmachines)) == NULL)
goto cleanup;
if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_I686,
@@ -360,6 +414,10 @@ virCapsPtr testQemuCapsInit(void)
cleanup:
virCapabilitiesFreeMachines(machines, nmachines);
+ if (caps->host.cpu != cpuDefault)
+ virCPUDefFree(cpuDefault);
+ if (caps->host.cpu != cpuHaswell)
+ virCPUDefFree(cpuHaswell);
virObjectUnref(caps);
return NULL;
}
diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h
index 79ee1434c2..0ec5dadd2f 100644
--- a/tests/testutilsqemu.h
+++ b/tests/testutilsqemu.h
@@ -10,4 +10,10 @@ virDomainXMLOptionPtr testQemuXMLConfInit(void);
extern qemuBuildCommandLineCallbacks testCallbacks;
virQEMUCapsPtr qemuTestParseCapabilities(const char *capsFile);
+
+extern virCPUDefPtr cpuDefault;
+extern virCPUDefPtr cpuHaswell;
+void testQemuCapsSetCPU(virCapsPtr caps,
+ virCPUDefPtr hostCPU);
+
#endif