From: Collin Walling Date: Thu, 20 Nov 2025 22:34:43 +0000 (-0500) Subject: qemu: only allow enabling deprecated features that are supported X-Git-Tag: v11.10.0-rc1~55 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=029933be861be2a8c6c0d55a6cbb3ee0a6419d0a;p=thirdparty%2Flibvirt.git qemu: only allow enabling deprecated features that are supported 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 Reviewed-by: Jiri Denemark --- 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); } }