[libvirt PATCH] qemu: do not compare missing cpu data

Ján Tomko posted 1 patch 2 years, 4 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/3d4901a58cd4345a2894204baeccd9196a4820cb.1638966234.git.jtomko@redhat.com
src/qemu/qemu_capabilities.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[libvirt PATCH] qemu: do not compare missing cpu data
Posted by Ján Tomko 2 years, 4 months ago
For x86, we invalidate qemu caps cache if the host CPUID changed.
However other cpu drivers do not have the 'getHostData' function
implemented.

Skip the comparison if we do not have host CPUData available,
since virCPUDataIsIdentical always returns an error in that case.

https://bugzilla.redhat.com/show_bug.cgi?id=2030119

Fixes: 3bc6f46d305ed82f7314ffc4c2a66847b831a6bd
Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 src/qemu/qemu_capabilities.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 0e6e73774a..51828ead53 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4943,7 +4943,8 @@ virQEMUCapsIsValid(void *data,
             return false;
         }
 
-        if (virCPUDataIsIdentical(priv->cpuData, qemuCaps->cpuData) !=
+        if (priv->cpuData &&
+            virCPUDataIsIdentical(priv->cpuData, qemuCaps->cpuData) !=
             VIR_CPU_COMPARE_IDENTICAL) {
             VIR_DEBUG("Outdated capabilities for '%s': host cpuid changed",
                       qemuCaps->binary);
-- 
2.31.1

Re: [libvirt PATCH] qemu: do not compare missing cpu data
Posted by Jiri Denemark 2 years, 4 months ago
On Wed, Dec 08, 2021 at 13:24:04 +0100, Ján Tomko wrote:
> For x86, we invalidate qemu caps cache if the host CPUID changed.
> However other cpu drivers do not have the 'getHostData' function
> implemented.
> 
> Skip the comparison if we do not have host CPUData available,
> since virCPUDataIsIdentical always returns an error in that case.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=2030119
> 
> Fixes: 3bc6f46d305ed82f7314ffc4c2a66847b831a6bd
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  src/qemu/qemu_capabilities.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index 0e6e73774a..51828ead53 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -4943,7 +4943,8 @@ virQEMUCapsIsValid(void *data,
>              return false;
>          }
>  
> -        if (virCPUDataIsIdentical(priv->cpuData, qemuCaps->cpuData) !=
> +        if (priv->cpuData &&
> +            virCPUDataIsIdentical(priv->cpuData, qemuCaps->cpuData) !=
>              VIR_CPU_COMPARE_IDENTICAL) {

While at it you could have placed VIR_CPU_COMPARE_IDENTICAL at the end
of the previous line.

>              VIR_DEBUG("Outdated capabilities for '%s': host cpuid changed",
>                        qemuCaps->binary);

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>