libvirt/SOURCES/libvirt-qemu-Avoid-crash-in-qemuDomainCheckCPU-with-unknown-host-CPU.patch
2025-05-13 09:18:07 +03:00

39 lines
1.5 KiB
Diff

From d874530eaded03d0b90139c9bbd80902b9464e87 Mon Sep 17 00:00:00 2001
Message-ID: <d874530eaded03d0b90139c9bbd80902b9464e87.1741876175.git.jdenemar@redhat.com>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Tue, 18 Feb 2025 11:24:32 +0100
Subject: [PATCH] qemu: Avoid crash in qemuDomainCheckCPU with unknown host CPU
When we don't have any information about host CPU (for example when
running on an aarch64 host), the virQEMUCapsGetHostModel would return
NULL.
Fixes: f928eb5fc80ca0ed7277f2513b63aed36c09d275
Fixes: https://gitlab.com/libvirt/libvirt/-/issues/747
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Tested-by: Jaroslav Suchanek <jsuchane@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 43eae1b7077104d4e2ed52447407a335c2d093e3)
https://issues.redhat.com/browse/RHEL-81747
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
src/qemu/qemu_domain.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 92035dd281..1ccaff90d9 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -11446,6 +11446,7 @@ qemuDomainCheckCPU(virArch arch,
/* Force compat check if the CPU model is not found in qemuCaps or
* we don't have host CPU data from QEMU */
if (!cpu->model ||
+ !hypervisorCPU ||
hypervisorCPU->fallback != VIR_CPU_FALLBACK_FORBID ||
virQEMUCapsGetCPUBlockers(qemuCaps, virtType,
cpu->model, &blockers) < 0)
--
2.48.1