[PULL 4/4] ui/vnc: Fix qemu abort when query vnc info

marcandre.lureau@redhat.com posted 4 patches 2 months, 2 weeks ago
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
[PULL 4/4] ui/vnc: Fix qemu abort when query vnc info
Posted by marcandre.lureau@redhat.com 2 months, 2 weeks ago
From: "AlanoSong@163.com" <AlanoSong@163.com>

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().

Reviewed-by: Marc-AndréLureau <marcandre.lureau@redhat.com>
Signed-off-by: Alano Song <AlanoSong@163.com>
[ Marc-André - removed useless Error *err ]
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20251125131955.7024-1-AlanoSong@163.com>
---
 ui/vnc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 0d499b208b..e6bcf0e1cf 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -556,9 +556,12 @@ 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);
+            Object *obj = object_property_get_link(OBJECT(vd->dcl.con),
+                                                   "device", NULL);
+            if (obj) {
+                dev = DEVICE(obj);
+                info->display = g_strdup(dev->id);
+            }
         }
         if (vd->listener != NULL) {
             nsioc = qio_net_listener_nsioc(vd->listener);
-- 
2.51.1


Re: [PULL 4/4] ui/vnc: Fix qemu abort when query vnc info
Posted by Philippe Mathieu-Daudé 2 months, 2 weeks ago
On 25/11/25 15:17, marcandre.lureau@redhat.com wrote:
> From: "AlanoSong@163.com" <AlanoSong@163.com>
> 
> 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().
> 
> Reviewed-by: Marc-AndréLureau <marcandre.lureau@redhat.com>

                          ^

> Signed-off-by: Alano Song <AlanoSong@163.com>
> [ Marc-André - removed useless Error *err ]
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Message-ID: <20251125131955.7024-1-AlanoSong@163.com>
> ---
>   ui/vnc.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)