ui/vnc: Fix qemu abort when query vnc info
RFC 1/1 ui/vnc: Fix qemu abort when query vnc info
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().
--- ui/vnc.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
ui/vnc.c +14 -3
@@ -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" ); + } + }else { + info->display =g_strdup ("none" ); +error_free (err); + } }if (vd->listener !=NULL ) { nsioc =qio_net_listener_nsioc (vd->listener);
Signature · 1 line
2.43.0
Hi
Quoted 7 lines · 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 inputinfo vncby QMP, the qemu will abort.
Quoted 5 lines
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
Quoted 17 lines
--- ui/vnc.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)ui/vnc.c +1
-3@@ -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 ;
ui/vnc.c VncInfo2List *qmp_query_vnc_servers(Error **errp) · line 570
Quoted 10 lines
ui/vnc.c +9
-0+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 {
ui/vnc.c VncInfo2List *qmp_query_vnc_servers(Error **errp) · line 572
Quoted 2 lines
ui/vnc.c +1
-0+ 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);
Quoted 8 lines
ui/vnc.c +1
-1+ } }if (vd->listener !=NULL ) { nsioc =qio_net_listener_nsioc (vd->listener); --2.43.0