From: "[email protected]" <[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().

Reviewed-by: Marc-AndréLureau <[email protected]>
Signed-off-by: Alano Song <[email protected]>
[ Marc-André - removed useless Error *err ]
Signed-off-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected]>
(cherry picked from commit 4c1646e23f761e3dc6d88c8995f13be8f668a012)
Signed-off-by: Michael Tokarev <[email protected]>

diff --git a/ui/vnc.c b/ui/vnc.c
index 9054fc8125..88e55ca797 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -555,9 +555,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);
+            }
         }
         for (i = 0; vd->listener != NULL && i < vd->listener->nsioc; i++) {
             info->server = qmp_query_server_entry(
-- 
2.47.3


Reply via email to