[PATCH] qemu: Avoid crash in qemuDomainCheckCPU with unknown host CPU

Jiri Denemark posted 1 patch 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1cde8daf2f86086014c41d170256c0214566e3e6.1739875793.git.jdenemar@redhat.com
src/qemu/qemu_domain.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] qemu: Avoid crash in qemuDomainCheckCPU with unknown host CPU
Posted by Jiri Denemark 10 months ago
When we don't have any information about host CPU (for example when
running on an aarch64 host), the virQEMUCapsGetHostModel would return
NULL.

Fixes: https://gitlab.com/libvirt/libvirt/-/issues/747
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 cf05dca55a..df1ed0223d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -11430,6 +11430,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
Re: [PATCH] qemu: Avoid crash in qemuDomainCheckCPU with unknown host CPU
Posted by Michal Prívozník 10 months ago
On 2/18/25 11:49, Jiri Denemark wrote:
> When we don't have any information about host CPU (for example when
> running on an aarch64 host), the virQEMUCapsGetHostModel would return
> NULL.
> 
> Fixes: https://gitlab.com/libvirt/libvirt/-/issues/747
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>

Please also mention:

Fixes: f928eb5fc80ca0ed7277f2513b63aed36c09d275

> ---
>  src/qemu/qemu_domain.c | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal
Re: [PATCH] qemu: Avoid crash in qemuDomainCheckCPU with unknown host CPU
Posted by Jaroslav Suchanek 10 months ago
On Tue, Feb 18, 2025 at 11:49:53AM +0100, Jiri Denemark wrote:
> When we don't have any information about host CPU (for example when
> running on an aarch64 host), the virQEMUCapsGetHostModel would return
> NULL.

Tested-by: Jaroslav Suchanek <jsuchane@redhat.com>

> 
> Fixes: https://gitlab.com/libvirt/libvirt/-/issues/747
> 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 cf05dca55a..df1ed0223d 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -11430,6 +11430,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
> 

-- 
J.