diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 5d101a40eae9abc6aeb29e880c3bf8d719b9831e..56080ef1f4007eac5c2c55e8efb50d675e4f2af6 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1851,6 +1851,8 @@ x86Baseline(virCPUDefPtr *cpus, const struct x86_vendor *vendor = NULL; struct x86_model *model = NULL; bool outputVendor = true; + const char *modelName; + bool matchingNames = true; if (!(map = virCPUx86GetMap())) goto error; @@ -1873,9 +1875,19 @@ x86Baseline(virCPUDefPtr *cpus, goto error; } + modelName = cpus[0]->model; for (i = 1; i < ncpus; i++) { const char *vn = NULL; + if (matchingNames && cpus[i]->model) { + if (!modelName) { + modelName = cpus[i]->model; + } else if (STRNEQ(modelName, cpus[i]->model)) { + modelName = NULL; + matchingNames = false; + } + } + if (!(model = x86ModelFromCPU(cpus[i], map, VIR_CPU_FEATURE_REQUIRE))) goto error; @@ -1923,9 +1935,12 @@ x86Baseline(virCPUDefPtr *cpus, if (vendor && virCPUx86DataAddCPUID(base_model->data, &vendor->cpuid) < 0) goto error; - if (x86Decode(cpu, base_model->data, models, nmodels, NULL, flags) < 0) + if (x86Decode(cpu, base_model->data, models, nmodels, modelName, flags) < 0) goto error; + if (STREQ_NULLABLE(cpu->model, modelName)) + cpu->fallback = VIR_CPU_FALLBACK_FORBID; + if (!outputVendor) VIR_FREE(cpu->vendor); diff --git a/tests/cputestdata/x86-baseline-3-expanded.xml b/tests/cputestdata/x86-baseline-3-expanded.xml index d196112b2723ccb0e6ad5b9ed444e6edc586a532..a7e57be76d6e6b3ec5e4e95aba4619c218612fb7 100644 --- a/tests/cputestdata/x86-baseline-3-expanded.xml +++ b/tests/cputestdata/x86-baseline-3-expanded.xml @@ -1,5 +1,5 @@ - Westmere + Westmere