cpu: Check blockers in virCPUCompareUnusable only if they exist

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>
This commit is contained in:
Jiri Denemark 2024-11-27 08:34:52 +01:00
parent 444f45135a
commit c0b6774d50

View File

@ -201,6 +201,7 @@ virCPUCompareUnusable(virArch arch,
char **blocker; char **blocker;
size_t i; size_t i;
if (blockers) {
for (blocker = blockers; *blocker; blocker++) { for (blocker = blockers; *blocker; blocker++) {
if (!(feat = virCPUDefFindFeature(cpu, *blocker)) || if (!(feat = virCPUDefFindFeature(cpu, *blocker)) ||
feat->policy != VIR_CPU_FEATURE_DISABLE) { feat->policy != VIR_CPU_FEATURE_DISABLE) {
@ -208,6 +209,7 @@ virCPUCompareUnusable(virArch arch,
virBufferAddLit(&features, ", "); virBufferAddLit(&features, ", ");
} }
} }
}
expanded = virCPUDefCopy(host); expanded = virCPUDefCopy(host);
if (virCPUExpandFeatures(arch, expanded) < 0) if (virCPUExpandFeatures(arch, expanded) < 0)