Subtract the migrate blocker data from the result if this flag
was specified.
---
src/bhyve/bhyve_driver.c | 3 +-
src/cpu/cpu_x86.c | 9 +++++-
src/qemu/qemu_driver.c | 3 +-
tests/cputest.c | 6 ++++
tests/cputestdata/x86-baseline-6-migratable.xml | 10 +++++++
tests/cputestdata/x86-baseline-6-result.xml | 11 ++++++++
tests/cputestdata/x86-baseline-6.xml | 37 +++++++++++++++++++++++++
7 files changed, 76 insertions(+), 3 deletions(-)
create mode 100644 tests/cputestdata/x86-baseline-6-migratable.xml
create mode 100644 tests/cputestdata/x86-baseline-6-result.xml
create mode 100644 tests/cputestdata/x86-baseline-6.xml
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 56cc8ab..2a1cd2f 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -1340,7 +1340,8 @@ bhyveConnectBaselineCPU(virConnectPtr conn,
{
char *cpu = NULL;
- virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, NULL);
+ virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
+ VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
if (virConnectBaselineCPUEnsureACL(conn) < 0)
goto cleanup;
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index f6e8eec..a95d15a 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1953,6 +1953,9 @@ x86Baseline(virCPUDefPtr *cpus,
const char *modelName;
bool matchingNames = true;
+ virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
+ VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
+
if (!(map = virCPUx86GetMap()))
goto error;
@@ -2025,6 +2028,9 @@ x86Baseline(virCPUDefPtr *cpus,
model = NULL;
}
+ if (flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE)
+ x86DataSubtract(base_model->data, map->migrate_blocker_data);
+
if (x86DataIsEmpty(base_model->data)) {
virReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("CPUs are incompatible"));
@@ -2034,7 +2040,8 @@ x86Baseline(virCPUDefPtr *cpus,
if (vendor && virCPUx86DataAddCPUID(base_model->data,
&vendor->cpuid) < 0)
goto error;
- if (x86Decode(cpu, base_model->data, models, nmodels, modelName, flags) < 0)
+ if (x86Decode(cpu, base_model->data, models, nmodels, modelName,
+ flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) < 0)
goto error;
if (STREQ_NULLABLE(cpu->model, modelName))
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index cf351e6..8eded5e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12376,7 +12376,8 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUTE_UNUSED,
{
char *cpu = NULL;
- virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, NULL);
+ virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
+ VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
if (virConnectBaselineCPUEnsureACL(conn) < 0)
goto cleanup;
diff --git a/tests/cputest.c b/tests/cputest.c
index e49ae24..ab3efdf 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -346,6 +346,8 @@ cpuTestBaseline(const void *arg)
if (data->flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES)
suffix = "expanded";
+ else if (data->flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE)
+ suffix = "migratable";
else
suffix = "result";
if (virAsprintf(&result, "%s-%s", data->name, suffix) < 0)
@@ -533,6 +535,8 @@ mymain(void)
char *label; \
if ((flags) & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) \
suffix = " (expanded)"; \
+ if ((flags) & VIR_CONNECT_BASELINE_CPU_MIGRATABLE) \
+ suffix = " (migratable)"; \
if (virAsprintf(&label, "%s%s", name, suffix) < 0) {
\
ret = -1; \
} else { \
@@ -612,6 +616,8 @@ mymain(void)
DO_TEST_BASELINE("x86", "4",
VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, 0);
DO_TEST_BASELINE("x86", "5", 0, 0);
DO_TEST_BASELINE("x86", "5",
VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, 0);
+ DO_TEST_BASELINE("x86", "6", 0, 0);
+ DO_TEST_BASELINE("x86", "6", VIR_CONNECT_BASELINE_CPU_MIGRATABLE,
0);
DO_TEST_BASELINE("ppc64", "incompatible-vendors", 0, -1);
DO_TEST_BASELINE("ppc64", "no-vendor", 0, 0);
diff --git a/tests/cputestdata/x86-baseline-6-migratable.xml
b/tests/cputestdata/x86-baseline-6-migratable.xml
new file mode 100644
index 0000000..3c2f38c
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-6-migratable.xml
@@ -0,0 +1,10 @@
+<cpu mode='custom' match='exact'>
+ <model fallback='allow'>SandyBridge</model>
+ <vendor>Intel</vendor>
+ <feature policy='require' name='hypervisor'/>
+ <feature policy='require' name='osxsave'/>
+ <feature policy='require' name='pcid'/>
+ <feature policy='require' name='ss'/>
+ <feature policy='require' name='vme'/>
+ <feature policy='disable' name='rdtscp'/>
+</cpu>
diff --git a/tests/cputestdata/x86-baseline-6-result.xml
b/tests/cputestdata/x86-baseline-6-result.xml
new file mode 100644
index 0000000..bea0beb
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-6-result.xml
@@ -0,0 +1,11 @@
+<cpu mode='custom' match='exact'>
+ <model fallback='allow'>SandyBridge</model>
+ <vendor>Intel</vendor>
+ <feature policy='require' name='invtsc'/>
+ <feature policy='require' name='hypervisor'/>
+ <feature policy='require' name='osxsave'/>
+ <feature policy='require' name='pcid'/>
+ <feature policy='require' name='ss'/>
+ <feature policy='require' name='vme'/>
+ <feature policy='disable' name='rdtscp'/>
+</cpu>
diff --git a/tests/cputestdata/x86-baseline-6.xml b/tests/cputestdata/x86-baseline-6.xml
new file mode 100644
index 0000000..9845b93
--- /dev/null
+++ b/tests/cputestdata/x86-baseline-6.xml
@@ -0,0 +1,37 @@
+<cpuTest>
+<cpu>
+ <arch>x86_64</arch>
+ <model>Westmere</model>
+ <vendor>Intel</vendor>
+ <topology sockets='4' cores='1' threads='1'/>
+ <feature name='hypervisor'/>
+ <feature name='avx'/>
+ <feature name='osxsave'/>
+ <feature name='xsave'/>
+ <feature name='tsc-deadline'/>
+ <feature name='x2apic'/>
+ <feature name='pcid'/>
+ <feature name='pclmuldq'/>
+ <feature name='ss'/>
+ <feature name='vme'/>
+ <feature name='invtsc'/>
+</cpu>
+<cpu>
+ <arch>x86_64</arch>
+ <model>Nehalem</model>
+ <vendor>Intel</vendor>
+ <topology sockets='4' cores='1' threads='1'/>
+ <feature name='aes'/>
+ <feature name='hypervisor'/>
+ <feature name='avx'/>
+ <feature name='osxsave'/>
+ <feature name='xsave'/>
+ <feature name='tsc-deadline'/>
+ <feature name='x2apic'/>
+ <feature name='pcid'/>
+ <feature name='pclmuldq'/>
+ <feature name='ss'/>
+ <feature name='vme'/>
+ <feature name='invtsc'/>
+</cpu>
+</cpuTest>
--
2.0.5