[RFC v2] ui/vnc: Fix qemu abort when query vnc info

AlanoSong@163.com posted 1 patch 2 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251125131955.7024-1-AlanoSong@163.com
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>
ui/vnc.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
[RFC v2] ui/vnc: Fix qemu abort when query vnc info
Posted by AlanoSong@163.com 2 months, 2 weeks ago
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>
---
 ui/vnc.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 0d499b208b..3a54a6d24b 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -556,9 +556,15 @@ 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);
+                info->display = g_strdup(dev->id);
+            } else {
+                error_free(err);
+            }
         }
         if (vd->listener != NULL) {
             nsioc = qio_net_listener_nsioc(vd->listener);
-- 
2.43.0


Re: [RFC v2] ui/vnc: Fix qemu abort when query vnc info
Posted by Michael Tokarev 2 months, 2 weeks ago
On 11/25/25 16:19, AlanoSong@163.com wrote:
> 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().

I'm picking this up for qemu stable series (10.0 & 10.1).

Thanks,

/mjt