[PATCH 11/14] qemu: Always fetch disabled features in qemuMonitorJSONGetGuestCPU

Jiri Denemark via Devel posted 14 patches 5 months, 1 week ago
[PATCH 11/14] qemu: Always fetch disabled features in qemuMonitorJSONGetGuestCPU
Posted by Jiri Denemark via Devel 5 months, 1 week ago
From: Jiri Denemark <jdenemar@redhat.com>

The function is always called with both enabled and disabled pointers
set.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_monitor_json.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 6fa2f447db..06e0f3794e 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6784,13 +6784,11 @@ qemuMonitorJSONGetGuestCPU(qemuMonitor *mon,
     if (qemuMonitorJSONCPUDataAddFeatures(cpuEnabled, propsEnabled, translate) < 0)
         return -1;
 
-    if (disabled &&
-        qemuMonitorJSONGetCPUDataDisabled(mon, cpuQOMPath, translate, cpuDisabled) < 0)
+    if (qemuMonitorJSONGetCPUDataDisabled(mon, cpuQOMPath, translate, cpuDisabled) < 0)
         return -1;
 
     *enabled = g_steal_pointer(&cpuEnabled);
-    if (disabled)
-        *disabled = g_steal_pointer(&cpuDisabled);
+    *disabled = g_steal_pointer(&cpuDisabled);
 
     return 0;
 }
-- 
2.51.0
Re: [PATCH 11/14] qemu: Always fetch disabled features in qemuMonitorJSONGetGuestCPU
Posted by Peter Krempa via Devel 5 months ago
On Thu, Sep 04, 2025 at 16:46:59 +0200, Jiri Denemark via Devel wrote:
> From: Jiri Denemark <jdenemar@redhat.com>
> 
> The function is always called with both enabled and disabled pointers
> set.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/qemu/qemu_monitor_json.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 6fa2f447db..06e0f3794e 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -6784,13 +6784,11 @@ qemuMonitorJSONGetGuestCPU(qemuMonitor *mon,
>      if (qemuMonitorJSONCPUDataAddFeatures(cpuEnabled, propsEnabled, translate) < 0)
>          return -1;
>  
> -    if (disabled &&
> -        qemuMonitorJSONGetCPUDataDisabled(mon, cpuQOMPath, translate, cpuDisabled) < 0)
> +    if (qemuMonitorJSONGetCPUDataDisabled(mon, cpuQOMPath, translate, cpuDisabled) < 0)
>          return -1;
>  
>      *enabled = g_steal_pointer(&cpuEnabled);
> -    if (disabled)
> -        *disabled = g_steal_pointer(&cpuDisabled);
> +    *disabled = g_steal_pointer(&cpuDisabled);


The common monitor code wrapper:

int
qemuMonitorGetGuestCPU(qemuMonitor *mon,
                       virArch arch,
                       bool qomListGet,
                       const char *cpuQOMPath,
                       qemuMonitorCPUFeatureTranslationCallback translate,
                       virCPUData **enabled,
                       virCPUData **disabled)
{
    VIR_DEBUG("arch=%s qomListGet%d cpuQOMPath=%s translate=%p "
              "enabled=%p disabled=%p",
              virArchToString(arch), qomListGet, cpuQOMPath, translate,
              enabled, disabled);

    QEMU_CHECK_MONITOR(mon);

    *enabled = NULL;
    if (disabled)
        *disabled = NULL;

    return qemuMonitorJSONGetGuestCPU(mon, arch, qomListGet, cpuQOMPath,
                                      translate, enabled, disabled);
}


Also checks 'disabled'. Fix that one too.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>