ui/vnc: Fix qemu abort when query vnc info

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>
This commit is contained in:
AlanoSong@163.com 2025-11-25 21:19:55 +08:00 committed by Marc-André Lureau
parent 303f604935
commit 4c1646e23f

View file

@ -556,10 +556,13 @@ 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));
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);
}