Some models are just aliases to other models. Make this relation
available to users via domain capabilities.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
Notes:
Version 2:
- new patch
docs/formatdomaincaps.rst | 8 +++++---
src/conf/domain_capabilities.c | 11 +++++++++--
src/conf/domain_capabilities.h | 4 +++-
src/qemu/qemu_capabilities.c | 10 +++++++---
tests/cputest.c | 5 +++--
5 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/docs/formatdomaincaps.rst b/docs/formatdomaincaps.rst
index 886a9f71e1..ed95af4fee 100644
--- a/docs/formatdomaincaps.rst
+++ b/docs/formatdomaincaps.rst
@@ -193,12 +193,12 @@ CPUs <formatdomain.html#cpu-model-and-topology>`__.
<feature policy='require' name='vmx'/>
</mode>
<mode name='custom' supported='yes'>
- <model usable='no' deprecated='no' vendor='Intel'>Broadwell</model>
+ <model usable='no' deprecated='no' vendor='Intel' canonical='Broadwell-v1'>Broadwell</model>
<blockers model='Broadwell'>
<feature name='hle'/>
<feature name='rtm'/>
</blockers>
- <model usable='yes' deprecated='no' vendor='Intel'>Broadwell-noTSX</model>
+ <model usable='yes' deprecated='no' vendor='Intel' canonical='Broadwell-v2'>Broadwell-noTSX</model>
<model usable='no' deprecated='no' vendor='AMD'>EPYC-Milan</model>
<blockers model='EPYC-Milan'>
<feature name='clzero'/>
@@ -265,7 +265,9 @@ more details about it:
the hypervisor's policy on usage of this model :since:`(since 7.1.0)`. The
``vendor`` attribute :since:`(since 8.9.0)` contains the vendor of the CPU
model for users who want to use CPU models with specific vendors only. CPU
- models with undefined vendor will be listed with ``vendor='unkwnown'``.
+ models with undefined vendor will be listed with ``vendor='unkwnown'``. The
+ ``canonical`` attribute :since:`(since 10.10.0)` contains a canonical name of
+ the CPU model if the model is actually an alias to another one.
I/O Threads
~~~~~~~~~~~
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 5f70a48cec..ab715b19d8 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -122,6 +122,7 @@ virDomainCapsCPUModelsDispose(void *obj)
g_free(cpuModels->models[i].name);
g_strfreev(cpuModels->models[i].blockers);
g_free(cpuModels->models[i].vendor);
+ g_free(cpuModels->models[i].canonical);
}
g_free(cpuModels->models);
@@ -184,7 +185,8 @@ virDomainCapsCPUModelsCopy(virDomainCapsCPUModels *old)
old->models[i].usable,
old->models[i].blockers,
old->models[i].deprecated,
- old->models[i].vendor);
+ old->models[i].vendor,
+ old->models[i].canonical);
}
return cpuModels;
@@ -197,7 +199,8 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModels *cpuModels,
virDomainCapsCPUUsable usable,
char **blockers,
bool deprecated,
- const char *vendor)
+ const char *vendor,
+ const char *canonical)
{
virDomainCapsCPUModel *cpu;
@@ -212,6 +215,7 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModels *cpuModels,
cpu->blockers = g_strdupv(blockers);
cpu->deprecated = deprecated;
cpu->vendor = g_strdup(vendor);
+ cpu->canonical = g_strdup(canonical);
}
@@ -430,6 +434,9 @@ virDomainCapsCPUCustomFormat(virBuffer *buf,
else
virBufferAddLit(buf, " vendor='unknown'");
+ if (model->canonical)
+ virBufferAsprintf(buf, " canonical='%s'", model->canonical);
+
virBufferAsprintf(buf, ">%s</model>\n", model->name);
if (model->blockers) {
diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h
index ef08046860..69dd1a15c1 100644
--- a/src/conf/domain_capabilities.h
+++ b/src/conf/domain_capabilities.h
@@ -189,6 +189,7 @@ struct _virDomainCapsCPUModel {
char **blockers; /* NULL-terminated list of usability blockers */
bool deprecated;
char *vendor;
+ char *canonical;
};
typedef struct _virDomainCapsCPUModels virDomainCapsCPUModels;
@@ -331,7 +332,8 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModels *cpuModels,
virDomainCapsCPUUsable usable,
char **blockers,
bool deprecated,
- const char *vendor);
+ const char *vendor,
+ const char *canonical);
virDomainCapsCPUModel *
virDomainCapsCPUModelsGet(virDomainCapsCPUModels *cpuModels,
const char *name);
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 5ac9f306f5..dec3199fce 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2144,7 +2144,7 @@ virQEMUCapsCPUDefsToModels(virArch arch,
qemuMonitorCPUDefs *defs,
const char **modelAllowed,
const char **modelForbidden,
- bool vendors)
+ bool extraInfo)
{
virDomainCapsCPUModels *cpuModels = NULL;
size_t i;
@@ -2155,6 +2155,7 @@ virQEMUCapsCPUDefsToModels(virArch arch,
for (i = 0; i < defs->ncpus; i++) {
qemuMonitorCPUDefInfo *cpu = defs->cpus + i;
const char *vendor = NULL;
+ const char *canonical = NULL;
if (modelAllowed && !g_strv_contains(modelAllowed, cpu->name))
continue;
@@ -2162,11 +2163,14 @@ virQEMUCapsCPUDefsToModels(virArch arch,
if (modelForbidden && g_strv_contains(modelForbidden, cpu->name))
continue;
- if (vendors)
+ if (extraInfo) {
vendor = virCPUGetVendorForModel(arch, cpu->name);
+ canonical = virCPUGetCanonicalModel(arch, cpu->name);
+ }
virDomainCapsCPUModelsAdd(cpuModels, cpu->name, cpu->usable,
- cpu->blockers, cpu->deprecated, vendor);
+ cpu->blockers, cpu->deprecated,
+ vendor, canonical);
}
virDomainCapsCPUModelsSort(cpuModels);
diff --git a/tests/cputest.c b/tests/cputest.c
index 32bf86997a..326ffebd09 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -823,7 +823,8 @@ cpuTestUpdateLive(const void *arg)
}
virDomainCapsCPUModelsAdd(models, expected->model,
- usable, blockers, false, expected->vendor);
+ usable, blockers, false,
+ expected->vendor, NULL);
cpu->fallback = VIR_CPU_FALLBACK_ALLOW;
ignore_value(virCPUTranslate(data->arch, cpu, models));
@@ -902,7 +903,7 @@ cpuTestInitModels(const char **list)
for (model = list; *model; model++) {
virDomainCapsCPUModelsAdd(cpus, *model,
VIR_DOMCAPS_CPU_USABLE_UNKNOWN,
- NULL, false, NULL);
+ NULL, false, NULL, NULL);
}
return cpus;
--
2.47.0