From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn81L-0000Mo-KE for qemu-devel@nongnu.org; Fri, 16 Oct 2015 12:38:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zn81G-0004wr-K8 for qemu-devel@nongnu.org; Fri, 16 Oct 2015 12:38:19 -0400 Received: from mail-qk0-x230.google.com ([2607:f8b0:400d:c09::230]:35268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn81G-0004w8-Gm for qemu-devel@nongnu.org; Fri, 16 Oct 2015 12:38:14 -0400 Received: by qkap81 with SMTP id p81so56748681qka.2 for ; Fri, 16 Oct 2015 09:38:11 -0700 (PDT) From: Julio Faracco Date: Fri, 16 Oct 2015 13:37:40 -0300 Message-Id: <1445013460-21104-1-git-send-email-jcfaracco@gmail.com> Subject: [Qemu-devel] [PATCH] qapi: Adding websocket information inside VncInfo structure. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Julio Faracco , armbru@redhat.com When the user setup a vnc server to QEMU using the argument "-vnc 0.0.0.0:0,websocket=5701" for example, he cannot get information about which websocket port VNC is running. The command "info vnc" shows only details about the main VNC server and the clients. You can confirm that a websocket service is running, checking the ports that are opened. This commit introduce two new fields inside "VncInfo" either: "webservice" which contains the port as a string and the boolean value "has_websocket" that copies the status of ws_enabled from VNC Display. Fixes #1486278 Signed-Off-By: Julio Faracco --- hmp.c | 3 +++ qapi-schema.json | 3 ++- ui/vnc.c | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/hmp.c b/hmp.c index 5048eee..3fc74e0 100644 --- a/hmp.c +++ b/hmp.c @@ -559,6 +559,9 @@ void hmp_info_vnc(Monitor *mon, const QDict *qdict) if (info->has_host && info->has_service) { monitor_printf(mon, " address: %s:%s\n", info->host, info->service); } + if(info->has_websocket) { + monitor_printf(mon, " websocket: %s:%s\n", info->host, info->webservice); + } if (info->has_auth) { monitor_printf(mon, " auth: %s\n", info->auth); } diff --git a/qapi-schema.json b/qapi-schema.json index a386605..e97f78f 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -916,7 +916,8 @@ { 'struct': 'VncInfo', 'data': {'enabled': 'bool', '*host': 'str', '*family': 'NetworkAddressFamily', - '*service': 'str', '*auth': 'str', '*clients': ['VncClientInfo']} } + '*service': 'str', '*auth': 'str', '*clients': ['VncClientInfo'], + '*webservice': 'str', 'has_websocket': 'bool'} } ## # @VncPriAuth: diff --git a/ui/vnc.c b/ui/vnc.c index d73966a..68b5960 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -411,6 +411,7 @@ VncInfo *qmp_query_vnc(Error **errp) socklen_t salen = sizeof(sa); char host[NI_MAXHOST]; char serv[NI_MAXSERV]; + char webserv[NI_MAXSERV]; info->enabled = true; @@ -447,6 +448,30 @@ VncInfo *qmp_query_vnc(Error **errp) info->has_auth = true; info->auth = g_strdup(vnc_auth_name(vd)); + + info->has_websocket = vd->ws_enabled; + + if (vd->ws_enabled) { + if (vd->lwebsock == -1) { + return info; + } + + if (getsockname(vd->lwebsock, (struct sockaddr *)&sa, + &salen) == -1) { + error_setg(errp, QERR_UNDEFINED_ERROR); + goto out_error; + } + + if (getnameinfo((struct sockaddr *)&sa, salen, + host, sizeof(host), + webserv, sizeof(serv), + NI_NUMERICHOST | NI_NUMERICSERV) < 0) { + error_setg(errp, QERR_UNDEFINED_ERROR); + goto out_error; + } + } + + info->webservice = g_strdup(webserv); } return info; -- 1.9.1