[PATCH] cpu: Do not call g_strv_contains on NULL list

Jiri Denemark posted 1 patch 6 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/82ab7b16b162bc0a751ebcb7325ca6ea9d7cfec1.1740406927.git.jdenemar@redhat.com
src/cpu/cpu_x86.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] cpu: Do not call g_strv_contains on NULL list
Posted by Jiri Denemark 6 months, 2 weeks ago
When virCPUx86UpdateLive checks whether a feature was added to a CPU
model after the model was already released (vmx-* features in most Intel
models), the following assert could be logged by glib:

    g_strv_contains: assertion 'strv != NULL' failed

While most of our CPU models have a non-empty list of added feature, new
models added in 2024 and versioned variants of older models have
addedFeatures == NULL.

Fixes: e622970c8785ec1f7e142d72f792d89f870e07d0
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/cpu/cpu_x86.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 67c88ae3b7..32aa01bc14 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -3212,6 +3212,7 @@ virCPUx86UpdateLive(virCPUDef *cpu,
          * behaved before the features were added.
          */
         if (!explicit &&
+            model->addedFeatures &&
             g_strv_contains((const char **) model->addedFeatures, feature->name))
             ignore = true;
 
-- 
2.48.1
Re: [PATCH] cpu: Do not call g_strv_contains on NULL list
Posted by Michal Prívozník 6 months, 2 weeks ago
On 2/24/25 15:22, Jiri Denemark wrote:
> When virCPUx86UpdateLive checks whether a feature was added to a CPU
> model after the model was already released (vmx-* features in most Intel
> models), the following assert could be logged by glib:
> 
>     g_strv_contains: assertion 'strv != NULL' failed
> 
> While most of our CPU models have a non-empty list of added feature, new
> models added in 2024 and versioned variants of older models have
> addedFeatures == NULL.
> 
> Fixes: e622970c8785ec1f7e142d72f792d89f870e07d0
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/cpu/cpu_x86.c | 1 +
>  1 file changed, 1 insertion(+)
> 

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