When updating the guest CPU model and the deprecated_features attribute
is set to on, only enable the features the model can actually enable.
While host-model would normally just enable these features without
intervention (and without the presence of the deprecated_features
attribute), custom models would see no changes to their feature set
without these changes.
This is useful for e.g. testing CPU models.
Fixes: f279ea36 (qemu: process: refactor deprecated features code)
Signed-off-by: Collin Walling <walling@linux.ibm.com>
---
src/qemu/qemu_capabilities.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 2dfdedfa1a..cee7a0f5ef 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3437,15 +3437,24 @@ virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps,
virCPUFeaturePolicy policy)
{
qemuMonitorCPUModelInfo *modelInfo;
+ GStrv props;
size_t i;
modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, virtType);
- if (!modelInfo || !modelInfo->full_dep_props)
+ if (!modelInfo)
return;
- for (i = 0; i < g_strv_length(modelInfo->full_dep_props); i++) {
- virCPUDefUpdateFeature(cpu, modelInfo->full_dep_props[i], policy);
+ /* Only allow policy "require" on features that are actually
+ * supported on the CPU model */
+ if (policy == VIR_CPU_FEATURE_REQUIRE) {
+ props = modelInfo->static_dep_props;
+ } else {
+ props = modelInfo->full_dep_props;
+ }
+
+ for (i = 0; i < g_strv_length(props); i++) {
+ virCPUDefUpdateFeature(cpu, props[i], policy);
}
}
--
2.51.1
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
On 11/20/25 23:34, Collin Walling wrote:
> When updating the guest CPU model and the deprecated_features attribute
> is set to on, only enable the features the model can actually enable.
>
> While host-model would normally just enable these features without
> intervention (and without the presence of the deprecated_features
> attribute), custom models would see no changes to their feature set
> without these changes.
>
> This is useful for e.g. testing CPU models.
>
> Fixes: f279ea36 (qemu: process: refactor deprecated features code)
> Signed-off-by: Collin Walling <walling@linux.ibm.com>
> ---
> src/qemu/qemu_capabilities.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 2dfdedfa1a..cee7a0f5ef 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -3437,15 +3437,24 @@ virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps,
> virCPUFeaturePolicy policy)
> {
> qemuMonitorCPUModelInfo *modelInfo;
> + GStrv props;
> size_t i;
>
> modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, virtType);
>
> - if (!modelInfo || !modelInfo->full_dep_props)
> + if (!modelInfo)
> return;
>
> - for (i = 0; i < g_strv_length(modelInfo->full_dep_props); i++) {
> - virCPUDefUpdateFeature(cpu, modelInfo->full_dep_props[i], policy);
> + /* Only allow policy "require" on features that are actually
> + * supported on the CPU model */
> + if (policy == VIR_CPU_FEATURE_REQUIRE) {
> + props = modelInfo->static_dep_props;
> + } else {
> + props = modelInfo->full_dep_props;
> + }
> +
> + for (i = 0; i < g_strv_length(props); i++) {
> + virCPUDefUpdateFeature(cpu, props[i], policy);
> }
> }
>
--
Mit freundlichen Grüßen/Kind regards
Boris Fiuczynski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
© 2016 - 2026 Red Hat, Inc.