]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu: Check blockers in virCPUCompareUnusable only if they exist
authorJiri Denemark <jdenemar@redhat.com>
Wed, 27 Nov 2024 07:34:52 +0000 (08:34 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 27 Nov 2024 13:50:44 +0000 (14:50 +0100)
virCPUCompareUnusable can be called with blockers == NULL in case the
CPU model itself is usable (i.e., QEMU reports an empty list of
blockers), but the CPU definition contains some additional features
which have to be checked.

Fixes: v10.8.0-129-g5f8abbb7d0
Reported-by: Han Han <hhan@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Tested-by: Han Han <hhan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/cpu/cpu.c

index ef515744bab8378cf046b86eed094d224f174fbd..77afb7e9b3a4e1fa8c1f44267840917857c96e61 100644 (file)
@@ -201,11 +201,13 @@ virCPUCompareUnusable(virArch arch,
     char **blocker;
     size_t i;
 
-    for (blocker = blockers; *blocker; blocker++) {
-        if (!(feat = virCPUDefFindFeature(cpu, *blocker)) ||
-            feat->policy != VIR_CPU_FEATURE_DISABLE) {
-            virBufferAddStr(&features, *blocker);
-            virBufferAddLit(&features, ", ");
+    if (blockers) {
+        for (blocker = blockers; *blocker; blocker++) {
+            if (!(feat = virCPUDefFindFeature(cpu, *blocker)) ||
+                feat->policy != VIR_CPU_FEATURE_DISABLE) {
+                virBufferAddStr(&features, *blocker);
+                virBufferAddLit(&features, ", ");
+            }
         }
     }