Hi

On Tue, Nov 25, 2025 at 4:32 PM <[email protected]> wrote:

> From: Alano Song <[email protected]>
>
> When there is no display device on qemu machine,
> and user only access qemu by remote vnc.
> At the same time user input `info vnc` by QMP,
> the qemu will abort.
>
> To avoid the abort above, I add display device check,
> when query vnc info in qmp_query_vnc_servers().
>
> Signed-off-by: Alano Song <[email protected]>
>

Good catch, lgtm


> ---
>  ui/vnc.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/ui/vnc.c b/ui/vnc.c
> index 0d499b208b..2fa79a5494 100644
> --- a/ui/vnc.c
> +++ b/ui/vnc.c
> @@ -556,9 +556,20 @@ VncInfo2List *qmp_query_vnc_servers(Error **errp)
>          qmp_query_auth(vd->auth, vd->subauth, &info->auth,
>                         &info->vencrypt, &info->has_vencrypt);
>          if (vd->dcl.con) {
> -            dev = DEVICE(object_property_get_link(OBJECT(vd->dcl.con),
> -                                                  "device",
> &error_abort));
> -            info->display = g_strdup(dev->id);
> +            Error *err = NULL;
> +            Object *obj = object_property_get_link(OBJECT(vd->dcl.con),
> +                                                   "device", &err);
> +            if (obj) {
> +                dev = DEVICE(obj);
> +                if (dev && dev->id) {
> +                    info->display = g_strdup(dev->id);
> +                } else {
> +                    info->display = g_strdup("unknown");
> +                }
>

info->display = g_strdup(dev->id);

as it is fine, it will set it to NULL if doesn't have an id.

+            } else {
> +                info->display = g_strdup("none");
>

This should be dropped. This way the "display" field isn't even produced,
and client can distinguish the case of associated/non-associated display.



+                error_free(err);
> +            }
>          }
>          if (vd->listener != NULL) {
>              nsioc = qio_net_listener_nsioc(vd->listener);
> --
> 2.43.0
>
>

Reply via email to