[libvirt PATCH] qemu: fix recording of CPU deprecations

Daniel P. Berrangé posted 1 patch 2 years, 1 month ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20220317175322.3946790-1-berrange@redhat.com
src/qemu/qemu_monitor_json.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
[libvirt PATCH] qemu: fix recording of CPU deprecations
Posted by Daniel P. Berrangé 2 years, 1 month ago
The code parsing thue query-cpu-definitions response will short-circuit
the for loop in the case where usable=yes, resulting in us failing to
parse the CPU deprecation flag.

IOW, we only reported deprecations in domain capabilities for CPU models
which were not runnable on the host.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/qemu/qemu_monitor_json.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 27c5e1c992..d5622bd6d9 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5309,10 +5309,9 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitor *mon,
             if (g_strv_length(cpu->blockers) == 0) {
                 cpu->usable = VIR_DOMCAPS_CPU_USABLE_YES;
                 g_clear_pointer(&cpu->blockers, g_strfreev);
-                continue;
+            } else {
+                cpu->usable = VIR_DOMCAPS_CPU_USABLE_NO;
             }
-
-            cpu->usable = VIR_DOMCAPS_CPU_USABLE_NO;
         }
 
         if (virJSONValueObjectHasKey(child, "deprecated") &&
-- 
2.34.1

Re: [libvirt PATCH] qemu: fix recording of CPU deprecations
Posted by Michal Prívozník 2 years, 1 month ago
On 3/17/22 18:53, Daniel P. Berrangé wrote:
> The code parsing thue query-cpu-definitions response will short-circuit
> the for loop in the case where usable=yes, resulting in us failing to
> parse the CPU deprecation flag.
> 
> IOW, we only reported deprecations in domain capabilities for CPU models
> which were not runnable on the host.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  src/qemu/qemu_monitor_json.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 27c5e1c992..d5622bd6d9 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -5309,10 +5309,9 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitor *mon,
>              if (g_strv_length(cpu->blockers) == 0) {
>                  cpu->usable = VIR_DOMCAPS_CPU_USABLE_YES;
>                  g_clear_pointer(&cpu->blockers, g_strfreev);
> -                continue;
> +            } else {
> +                cpu->usable = VIR_DOMCAPS_CPU_USABLE_NO;
>              }
> -
> -            cpu->usable = VIR_DOMCAPS_CPU_USABLE_NO;
>          }
>  
>          if (virJSONValueObjectHasKey(child, "deprecated") &&

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

Michal