qemu: report whether a CPU model is deprecated in dom capabilities

QEMU has the ability to mark CPUs as deprecated. This should be exposed
to management applications in the domain capabilities.

This attribute is only set when the model is actually deprecated.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2021-01-22 11:15:08 +00:00
parent f9f11c4ae8
commit 5138a09260
17 changed files with 72 additions and 40 deletions

View File

@ -214,9 +214,9 @@
&lt;feature policy='require' name='vmx'/&gt;
&lt;/mode&gt;
&lt;mode name='custom' supported='yes'&gt;
&lt;model usable='no'&gt;Broadwell&lt;/model&gt;
&lt;model usable='yes'&gt;Broadwell-noTSX&lt;/model&gt;
&lt;model usable='no'&gt;Haswell&lt;/model&gt;
&lt;model usable='no' deprecated='no'&gt;Broadwell&lt;/model&gt;
&lt;model usable='yes' deprecated='no'&gt;Broadwell-noTSX&lt;/model&gt;
&lt;model usable='no' deprecated='yes'&gt;Haswell&lt;/model&gt;
...
&lt;/mode&gt;
&lt;/cpu&gt;
@ -262,7 +262,9 @@
cannot be used without disabling some features that the CPU of such
model is expected to have. A special value <code>unknown</code>
indicates libvirt does not have enough information to provide the
usability data.
usability data. The <code>deprecated</code> attribute reflects
the hypervisor's policy on usage of this model
<span class="since">(since 7.1.0)</span>.
</dd>
</dl>

View File

@ -138,6 +138,14 @@
<value>unknown</value>
</choice>
</attribute>
<optional>
<attribute name="deprecated">
<choice>
<value>yes</value>
<value>no</value>
</choice>
</attribute>
</optional>
<text/>
</element>
</zeroOrMore>

View File

@ -175,7 +175,8 @@ virDomainCapsCPUModelsCopy(virDomainCapsCPUModelsPtr old)
if (virDomainCapsCPUModelsAdd(cpuModels,
old->models[i].name,
old->models[i].usable,
old->models[i].blockers) < 0)
old->models[i].blockers,
old->models[i].deprecated) < 0)
goto error;
}
@ -191,7 +192,8 @@ int
virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
const char *name,
virDomainCapsCPUUsable usable,
char **blockers)
char **blockers,
bool deprecated)
{
g_autofree char * nameCopy = NULL;
virDomainCapsCPUModelPtr cpu;
@ -208,6 +210,7 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
cpu->usable = usable;
cpu->name = g_steal_pointer(&nameCopy);
cpu->blockers = g_strdupv(blockers);
cpu->deprecated = deprecated;
return 0;
}
@ -388,8 +391,11 @@ virDomainCapsCPUCustomFormat(virBufferPtr buf,
for (i = 0; i < custom->nmodels; i++) {
virDomainCapsCPUModelPtr model = custom->models + i;
virBufferAsprintf(buf, "<model usable='%s'>%s</model>\n",
virDomainCapsCPUUsableTypeToString(model->usable),
virBufferAsprintf(buf, "<model usable='%s'",
virDomainCapsCPUUsableTypeToString(model->usable));
if (model->deprecated)
virBufferAddLit(buf, " deprecated='yes'");
virBufferAsprintf(buf, ">%s</model>\n",
model->name);
}

View File

@ -146,6 +146,7 @@ struct _virDomainCapsCPUModel {
char *name;
virDomainCapsCPUUsable usable;
char **blockers; /* NULL-terminated list of usability blockers */
bool deprecated;
};
typedef struct _virDomainCapsCPUModels virDomainCapsCPUModels;
@ -228,7 +229,8 @@ virDomainCapsCPUModelsPtr virDomainCapsCPUModelsCopy(virDomainCapsCPUModelsPtr o
int virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
const char *name,
virDomainCapsCPUUsable usable,
char **blockers);
char **blockers,
bool deprecated);
virDomainCapsCPUModelPtr
virDomainCapsCPUModelsGet(virDomainCapsCPUModelsPtr cpuModels,
const char *name);

View File

@ -2184,7 +2184,7 @@ virQEMUCapsCPUDefsToModels(qemuMonitorCPUDefsPtr defs,
continue;
if (virDomainCapsCPUModelsAdd(cpuModels, cpu->name, cpu->usable,
cpu->blockers) < 0)
cpu->blockers, cpu->deprecated) < 0)
return NULL;
}
@ -3904,6 +3904,7 @@ virQEMUCapsLoadCPUModels(virQEMUCapsAccelPtr caps,
int usable = VIR_DOMCAPS_CPU_USABLE_UNKNOWN;
g_autofree char * strUsable = NULL;
g_autofree xmlNodePtr * blockerNodes = NULL;
g_autofree char *deprecated = NULL;
int nblockers;
if ((strUsable = virXMLPropString(nodes[i], "usable")) &&
@ -3948,6 +3949,11 @@ virQEMUCapsLoadCPUModels(virQEMUCapsAccelPtr caps,
}
}
}
deprecated = virXMLPropString(nodes[i], "deprecated");
if (deprecated &&
STREQ(deprecated, "yes"))
cpu->deprecated = true;
}
caps->cpuModels = g_steal_pointer(&defs);
@ -4456,6 +4462,8 @@ virQEMUCapsFormatCPUModels(virQEMUCapsAccelPtr caps,
virBufferAsprintf(buf, " usable='%s'",
virDomainCapsCPUUsableTypeToString(cpu->usable));
}
if (cpu->deprecated)
virBufferAddLit(buf, " deprecated='yes'");
if (cpu->blockers) {
size_t j;

View File

@ -3673,6 +3673,7 @@ qemuMonitorCPUDefsCopy(qemuMonitorCPUDefsPtr src)
cpuDst->name = g_strdup(cpuSrc->name);
cpuDst->type = g_strdup(cpuSrc->type);
cpuDst->blockers = g_strdupv(cpuSrc->blockers);
cpuDst->deprecated = cpuSrc->deprecated;
}
return g_steal_pointer(&defs);

View File

@ -1193,6 +1193,7 @@ struct _qemuMonitorCPUDefInfo {
char *name;
char *type;
char **blockers; /* NULL-terminated string list */
bool deprecated;
};
typedef struct _qemuMonitorCPUDefs qemuMonitorCPUDefs;

View File

@ -5896,6 +5896,10 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
cpu->usable = VIR_DOMCAPS_CPU_USABLE_NO;
}
if (virJSONValueObjectHasKey(child, "deprecated") &&
virJSONValueObjectGetBoolean(child, "deprecated", &cpu->deprecated) < 0)
return -1;
}
*cpuDefs = g_steal_pointer(&defs);

View File

@ -846,7 +846,7 @@ cpuTestUpdateLive(const void *arg)
}
if (virDomainCapsCPUModelsAdd(models, expected->model,
usable, blockers) < 0)
usable, blockers, false) < 0)
goto cleanup;
cpu->fallback = VIR_CPU_FALLBACK_ALLOW;
@ -953,7 +953,7 @@ cpuTestInitModels(const char **list)
for (model = list; *model; model++) {
if (virDomainCapsCPUModelsAdd(cpus, *model,
VIR_DOMCAPS_CPU_USABLE_UNKNOWN, NULL) < 0)
VIR_DOMCAPS_CPU_USABLE_UNKNOWN, NULL, false) < 0)
goto error;
}

View File

@ -91,8 +91,8 @@
<model usable='no'>IvyBridge</model>
<model usable='no'>Icelake-Server-noTSX</model>
<model usable='no'>Icelake-Server</model>
<model usable='no'>Icelake-Client-noTSX</model>
<model usable='no'>Icelake-Client</model>
<model usable='no' deprecated='yes'>Icelake-Client-noTSX</model>
<model usable='no' deprecated='yes'>Icelake-Client</model>
<model usable='no'>Haswell-noTSX-IBRS</model>
<model usable='no'>Haswell-noTSX</model>
<model usable='no'>Haswell-IBRS</model>

View File

@ -96,8 +96,8 @@
<model usable='no'>IvyBridge</model>
<model usable='no'>Icelake-Server-noTSX</model>
<model usable='no'>Icelake-Server</model>
<model usable='no'>Icelake-Client-noTSX</model>
<model usable='no'>Icelake-Client</model>
<model usable='no' deprecated='yes'>Icelake-Client-noTSX</model>
<model usable='no' deprecated='yes'>Icelake-Client</model>
<model usable='no'>Haswell-noTSX-IBRS</model>
<model usable='no'>Haswell-noTSX</model>
<model usable='no'>Haswell-IBRS</model>

View File

@ -90,8 +90,8 @@
<model usable='no'>IvyBridge</model>
<model usable='no'>Icelake-Server-noTSX</model>
<model usable='no'>Icelake-Server</model>
<model usable='no'>Icelake-Client-noTSX</model>
<model usable='no'>Icelake-Client</model>
<model usable='no' deprecated='yes'>Icelake-Client-noTSX</model>
<model usable='no' deprecated='yes'>Icelake-Client</model>
<model usable='no'>Haswell-noTSX-IBRS</model>
<model usable='no'>Haswell-noTSX</model>
<model usable='no'>Haswell-IBRS</model>

View File

@ -91,8 +91,8 @@
<model usable='no'>IvyBridge</model>
<model usable='no'>Icelake-Server-noTSX</model>
<model usable='no'>Icelake-Server</model>
<model usable='no'>Icelake-Client-noTSX</model>
<model usable='no'>Icelake-Client</model>
<model usable='no' deprecated='yes'>Icelake-Client-noTSX</model>
<model usable='no' deprecated='yes'>Icelake-Client</model>
<model usable='no'>Haswell-noTSX-IBRS</model>
<model usable='no'>Haswell-noTSX</model>
<model usable='no'>Haswell-IBRS</model>

View File

@ -96,8 +96,8 @@
<model usable='no'>IvyBridge</model>
<model usable='no'>Icelake-Server-noTSX</model>
<model usable='no'>Icelake-Server</model>
<model usable='no'>Icelake-Client-noTSX</model>
<model usable='no'>Icelake-Client</model>
<model usable='no' deprecated='yes'>Icelake-Client-noTSX</model>
<model usable='no' deprecated='yes'>Icelake-Client</model>
<model usable='no'>Haswell-noTSX-IBRS</model>
<model usable='no'>Haswell-noTSX</model>
<model usable='no'>Haswell-IBRS</model>

View File

@ -90,8 +90,8 @@
<model usable='no'>IvyBridge</model>
<model usable='no'>Icelake-Server-noTSX</model>
<model usable='no'>Icelake-Server</model>
<model usable='no'>Icelake-Client-noTSX</model>
<model usable='no'>Icelake-Client</model>
<model usable='no' deprecated='yes'>Icelake-Client-noTSX</model>
<model usable='no' deprecated='yes'>Icelake-Client</model>
<model usable='no'>Haswell-noTSX-IBRS</model>
<model usable='no'>Haswell-noTSX</model>
<model usable='no'>Haswell-IBRS</model>

View File

@ -1055,7 +1055,7 @@
<blocker name='avx512f'/>
<blocker name='pku'/>
</cpu>
<cpu type='kvm' name='Icelake-Client-v2' typename='Icelake-Client-v2-x86_64-cpu' usable='no'>
<cpu type='kvm' name='Icelake-Client-v2' typename='Icelake-Client-v2-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='pcid'/>
<blocker name='erms'/>
<blocker name='invpcid'/>
@ -1071,7 +1071,7 @@
<blocker name='spec-ctrl'/>
<blocker name='pku'/>
</cpu>
<cpu type='kvm' name='Icelake-Client-v1' typename='Icelake-Client-v1-x86_64-cpu' usable='no'>
<cpu type='kvm' name='Icelake-Client-v1' typename='Icelake-Client-v1-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='pcid'/>
<blocker name='hle'/>
<blocker name='erms'/>
@ -1089,7 +1089,7 @@
<blocker name='spec-ctrl'/>
<blocker name='pku'/>
</cpu>
<cpu type='kvm' name='Icelake-Client-noTSX' typename='Icelake-Client-noTSX-x86_64-cpu' usable='no'>
<cpu type='kvm' name='Icelake-Client-noTSX' typename='Icelake-Client-noTSX-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='pcid'/>
<blocker name='erms'/>
<blocker name='invpcid'/>
@ -1105,7 +1105,7 @@
<blocker name='spec-ctrl'/>
<blocker name='pku'/>
</cpu>
<cpu type='kvm' name='Icelake-Client' typename='Icelake-Client-x86_64-cpu' usable='no'>
<cpu type='kvm' name='Icelake-Client' typename='Icelake-Client-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='pcid'/>
<blocker name='hle'/>
<blocker name='erms'/>
@ -2429,7 +2429,7 @@
<blocker name='wbnoinvd'/>
<blocker name='xsavec'/>
</cpu>
<cpu type='tcg' name='Icelake-Client-v2' typename='Icelake-Client-v2-x86_64-cpu' usable='no'>
<cpu type='tcg' name='Icelake-Client-v2' typename='Icelake-Client-v2-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='fma'/>
<blocker name='pcid'/>
<blocker name='x2apic'/>
@ -2454,7 +2454,7 @@
<blocker name='wbnoinvd'/>
<blocker name='xsavec'/>
</cpu>
<cpu type='tcg' name='Icelake-Client-v1' typename='Icelake-Client-v1-x86_64-cpu' usable='no'>
<cpu type='tcg' name='Icelake-Client-v1' typename='Icelake-Client-v1-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='fma'/>
<blocker name='pcid'/>
<blocker name='x2apic'/>
@ -2481,7 +2481,7 @@
<blocker name='wbnoinvd'/>
<blocker name='xsavec'/>
</cpu>
<cpu type='tcg' name='Icelake-Client-noTSX' typename='Icelake-Client-noTSX-x86_64-cpu' usable='no'>
<cpu type='tcg' name='Icelake-Client-noTSX' typename='Icelake-Client-noTSX-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='fma'/>
<blocker name='pcid'/>
<blocker name='x2apic'/>
@ -2506,7 +2506,7 @@
<blocker name='wbnoinvd'/>
<blocker name='xsavec'/>
</cpu>
<cpu type='tcg' name='Icelake-Client' typename='Icelake-Client-x86_64-cpu' usable='no'>
<cpu type='tcg' name='Icelake-Client' typename='Icelake-Client-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='fma'/>
<blocker name='pcid'/>
<blocker name='x2apic'/>

View File

@ -1059,7 +1059,7 @@
<blocker name='avx512f'/>
<blocker name='pku'/>
</cpu>
<cpu type='kvm' name='Icelake-Client-v2' typename='Icelake-Client-v2-x86_64-cpu' usable='no'>
<cpu type='kvm' name='Icelake-Client-v2' typename='Icelake-Client-v2-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='pcid'/>
<blocker name='erms'/>
<blocker name='invpcid'/>
@ -1075,7 +1075,7 @@
<blocker name='spec-ctrl'/>
<blocker name='pku'/>
</cpu>
<cpu type='kvm' name='Icelake-Client-v1' typename='Icelake-Client-v1-x86_64-cpu' usable='no'>
<cpu type='kvm' name='Icelake-Client-v1' typename='Icelake-Client-v1-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='pcid'/>
<blocker name='hle'/>
<blocker name='erms'/>
@ -1093,7 +1093,7 @@
<blocker name='spec-ctrl'/>
<blocker name='pku'/>
</cpu>
<cpu type='kvm' name='Icelake-Client-noTSX' typename='Icelake-Client-noTSX-x86_64-cpu' usable='no'>
<cpu type='kvm' name='Icelake-Client-noTSX' typename='Icelake-Client-noTSX-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='pcid'/>
<blocker name='erms'/>
<blocker name='invpcid'/>
@ -1109,7 +1109,7 @@
<blocker name='spec-ctrl'/>
<blocker name='pku'/>
</cpu>
<cpu type='kvm' name='Icelake-Client' typename='Icelake-Client-x86_64-cpu' usable='no'>
<cpu type='kvm' name='Icelake-Client' typename='Icelake-Client-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='pcid'/>
<blocker name='hle'/>
<blocker name='erms'/>
@ -2438,7 +2438,7 @@
<blocker name='wbnoinvd'/>
<blocker name='xsavec'/>
</cpu>
<cpu type='tcg' name='Icelake-Client-v2' typename='Icelake-Client-v2-x86_64-cpu' usable='no'>
<cpu type='tcg' name='Icelake-Client-v2' typename='Icelake-Client-v2-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='fma'/>
<blocker name='pcid'/>
<blocker name='x2apic'/>
@ -2463,7 +2463,7 @@
<blocker name='wbnoinvd'/>
<blocker name='xsavec'/>
</cpu>
<cpu type='tcg' name='Icelake-Client-v1' typename='Icelake-Client-v1-x86_64-cpu' usable='no'>
<cpu type='tcg' name='Icelake-Client-v1' typename='Icelake-Client-v1-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='fma'/>
<blocker name='pcid'/>
<blocker name='x2apic'/>
@ -2490,7 +2490,7 @@
<blocker name='wbnoinvd'/>
<blocker name='xsavec'/>
</cpu>
<cpu type='tcg' name='Icelake-Client-noTSX' typename='Icelake-Client-noTSX-x86_64-cpu' usable='no'>
<cpu type='tcg' name='Icelake-Client-noTSX' typename='Icelake-Client-noTSX-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='fma'/>
<blocker name='pcid'/>
<blocker name='x2apic'/>
@ -2515,7 +2515,7 @@
<blocker name='wbnoinvd'/>
<blocker name='xsavec'/>
</cpu>
<cpu type='tcg' name='Icelake-Client' typename='Icelake-Client-x86_64-cpu' usable='no'>
<cpu type='tcg' name='Icelake-Client' typename='Icelake-Client-x86_64-cpu' usable='no' deprecated='yes'>
<blocker name='fma'/>
<blocker name='pcid'/>
<blocker name='x2apic'/>