diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index 86d94178b6..1148031bf1 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -511,6 +511,10 @@ cpuBaselineXML(const char **xmlCPUs,
size_t i;
VIR_DEBUG("ncpus=%u, nmodels=%u", ncpus, nmodels);
+
+ virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
+ VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
+
if (xmlCPUs) {
for (i = 0; i < ncpus; i++)
VIR_DEBUG("xmlCPUs[%zu]=%s", i, NULLSTR(xmlCPUs[i]));
@@ -551,6 +555,10 @@ cpuBaselineXML(const char **xmlCPUs,
if (!(cpu = cpuBaseline(cpus, ncpus, models, nmodels, flags)))
goto error;
+ if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
+ virCPUExpandFeatures(cpus[0]->arch, cpu) < 0)
+ goto error;
+
cpustr = virCPUDefFormat(cpu, NULL, false);
cleanup:
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 9c480398f0..388102f359 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -967,28 +967,6 @@ x86FeaturesLoad(virCPUx86MapPtr map,
return 0;
}
-static int
-x86DataFromCPUFeatures(virCPUx86Data *data,
- virCPUDefPtr cpu,
- virCPUx86MapPtr map)
-{
- size_t i;
-
- for (i = 0; i < cpu->nfeatures; i++) {
- virCPUx86FeaturePtr feature;
- if (!(feature = x86FeatureFind(map, cpu->features[i].name))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unknown CPU feature %s"), cpu->features[i].name);
- return -1;
- }
-
- if (x86DataAdd(data, &feature->data) < 0)
- return -1;
- }
-
- return 0;
-}
-
static virCPUx86ModelPtr
x86ModelNew(void)
@@ -1948,17 +1926,6 @@ x86Decode(virCPUDefPtr cpu,
}
}
- if (flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) {
- if (x86DataCopy(©, &model->data) < 0 ||
- x86DataFromCPUFeatures(&features, cpuModel, map) < 0)
- goto cleanup;
-
- x86DataSubtract(©, &features);
- if (x86DataToCPUFeatures(cpuModel, VIR_CPU_FEATURE_REQUIRE,
- ©, map) < 0)
- goto cleanup;
- }
-
if (vendor && VIR_STRDUP(cpu->vendor, vendor->name) < 0)
goto cleanup;
diff --git a/tests/cputest.c b/tests/cputest.c
index 917b1a34ca..e72b405278 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -325,6 +325,14 @@ cpuTestBaseline(const void *arg)
goto cleanup;
baseline = cpuBaseline(cpus, ncpus, NULL, 0, data->flags);
+
+ if (baseline &&
+ (data->flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
+ virCPUExpandFeatures(data->arch, baseline) < 0) {
+ virCPUDefFree(baseline);
+ baseline = NULL;
+ }
+
if (data->result < 0) {
virResetLastError();
if (!baseline) {
diff --git a/tests/cputestdata/x86_64-baseline-3-expanded.xml b/tests/cputestdata/x86_64-baseline-3-expanded.xml
index f0c2273d8e..82857e3d45 100644
--- a/tests/cputestdata/x86_64-baseline-3-expanded.xml
+++ b/tests/cputestdata/x86_64-baseline-3-expanded.xml
@@ -1,35 +1,35 @@
Westmere
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
-
-
-
+
diff --git a/tests/cputestdata/x86_64-baseline-4-expanded.xml b/tests/cputestdata/x86_64-baseline-4-expanded.xml
index 7e4578e1ac..e54eca026d 100644
--- a/tests/cputestdata/x86_64-baseline-4-expanded.xml
+++ b/tests/cputestdata/x86_64-baseline-4-expanded.xml
@@ -1,46 +1,46 @@
Westmere
Intel
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
-
-
-
+
+
+
+
+
diff --git a/tests/cputestdata/x86_64-baseline-5-expanded.xml b/tests/cputestdata/x86_64-baseline-5-expanded.xml
index daef2a78ff..2c1b400150 100644
--- a/tests/cputestdata/x86_64-baseline-5-expanded.xml
+++ b/tests/cputestdata/x86_64-baseline-5-expanded.xml
@@ -1,47 +1,47 @@
SandyBridge
Intel
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
+
+
+
+
+