When only some host CPUs given to cpuBaseline contain <vendor> element,
baseline CPU should not contain it. Otherwise the result would not be
compatible with the host CPUs without vendor. CPU vendors are still
taken into account when computing baseline CPU, it's just removed from
the result.
---
src/cpu/cpu_x86.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 26a5c3f..c6ab871 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1621,6 +1621,7 @@ x86Baseline(virCPUDefPtr *cpus,
unsigned int i;
const struct x86_vendor *vendor = NULL;
struct x86_model *model = NULL;
+ bool outputVendor = true;
if (!(map = x86LoadMap()))
goto error;
@@ -1634,8 +1635,9 @@ x86Baseline(virCPUDefPtr *cpus,
cpu->type = VIR_CPU_TYPE_GUEST;
cpu->match = VIR_CPU_MATCH_EXACT;
- if (cpus[0]->vendor &&
- !(vendor = x86VendorFind(map, cpus[0]->vendor))) {
+ if (!cpus[0]->vendor)
+ outputVendor = false;
+ else if (!(vendor = x86VendorFind(map, cpus[0]->vendor))) {
virCPUReportError(VIR_ERR_OPERATION_FAILED,
_("Unknown CPU vendor %s"), cpus[0]->vendor);
goto error;
@@ -1657,8 +1659,11 @@ x86Baseline(virCPUDefPtr *cpus,
if (cpus[i]->vendor)
vn = cpus[i]->vendor;
- else if (model->vendor)
- vn = model->vendor->name;
+ else {
+ outputVendor = false;
+ if (model->vendor)
+ vn = model->vendor->name;
+ }
if (vn) {
if (!vendor) {
@@ -1694,6 +1699,9 @@ x86Baseline(virCPUDefPtr *cpus,
if (x86Decode(cpu, data, models, nmodels, NULL) < 0)
goto error;
+ if (!outputVendor)
+ VIR_FREE(cpu->vendor);
+
VIR_FREE(cpu->arch);
cleanup:
--
1.7.3.1