]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: only allow enabling deprecated features that are supported
authorCollin Walling <walling@linux.ibm.com>
Thu, 20 Nov 2025 22:34:43 +0000 (17:34 -0500)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 21 Nov 2025 15:17:31 +0000 (16:17 +0100)
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>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_capabilities.c

index 2dfdedfa1a89ae7ded8c61e0cc9c6a1aa1501a3f..cee7a0f5ef53c31184d4db30eb40920003f11f17 100644 (file)
@@ -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);
     }
 }