diff mbox

[1/8] ui: fix regression handling bare 'websocket' option to -vnc

Message ID 20170105160701.22118-2-berrange@redhat.com
State New
Headers show

Commit Message

Daniel P. Berrangé Jan. 5, 2017, 4:06 p.m. UTC
The -vnc argument is documented as accepting two syntaxes for
the 'websocket' option, either a bare option name, or a port
number. If using the bare option name, it is supposed to apply
the display number as an offset to base port 5700. e.g.

  -vnc localhost:3,websocket

should listen on port 5703, however, this was broken in 2.3.0 since

  commit 4db14629c38611061fc19ec6927405923de84f08
  Author: Gerd Hoffmann <kraxel@redhat.com>
  Date:   Tue Sep 16 12:33:03 2014 +0200

    vnc: switch to QemuOpts, allow multiple servers

instead qemu tries to listen on port "on" which gets looked up in
/etc/services and fails.

Fixes bug: #1455912

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 ui/vnc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Eric Blake Jan. 6, 2017, 1:39 p.m. UTC | #1
On 01/05/2017 10:06 AM, Daniel P. Berrange wrote:
> The -vnc argument is documented as accepting two syntaxes for
> the 'websocket' option, either a bare option name, or a port
> number. If using the bare option name, it is supposed to apply
> the display number as an offset to base port 5700. e.g.
> 
>   -vnc localhost:3,websocket
> 
> should listen on port 5703, however, this was broken in 2.3.0 since
> 
>   commit 4db14629c38611061fc19ec6927405923de84f08
>   Author: Gerd Hoffmann <kraxel@redhat.com>
>   Date:   Tue Sep 16 12:33:03 2014 +0200
> 
>     vnc: switch to QemuOpts, allow multiple servers
> 
> instead qemu tries to listen on port "on" which gets looked up in
> /etc/services and fails.
> 
> Fixes bug: #1455912
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  ui/vnc.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox

Patch

diff --git a/ui/vnc.c b/ui/vnc.c
index 2c28a59..5039bd4 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3582,7 +3582,13 @@  void vnc_display_open(const char *id, Error **errp)
                 wsaddr->type = SOCKET_ADDRESS_KIND_INET;
                 inet = wsaddr->u.inet.data = g_new0(InetSocketAddress, 1);
                 inet->host = g_strdup(saddr->u.inet.data->host);
-                inet->port = g_strdup(websocket);
+                if (g_str_equal(websocket, "") ||
+                    g_str_equal(websocket, "on")) {
+                    inet->port = g_strdup_printf(
+                        "%d", (int)baseport + 5700);
+                } else {
+                    inet->port = g_strdup(websocket);
+                }
 
                 if (to) {
                     inet->has_to = true;