vnc: added initial websocket protocol support

This patch adds basic Websocket Protocol version 13 - RFC 6455 - support
to QEMU VNC. Binary encoding support on the client side is mandatory.

Because of the GnuTLS requirement the Websockets implementation is
optional (--enable-vnc-ws).

To activate Websocket support the VNC option "websocket"is used, for
example "-vnc :0,websocket".
The listen port for Websocket connections is (5700 + display) so if
QEMU VNC is started with :0 the Websocket port would be 5700.
As an alternative the Websocket port could be manually specified by
using ",websocket=<port>" instead.

Parts of the implementation base on Anthony Liguori's QEMU Websocket
patch from 2010 and on Joel Martin's LibVNC Websocket implementation.

Signed-off-by: Tim Hardeck <thardeck@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Tim Hardeck 2013-01-21 11:04:44 +01:00 committed by Anthony Liguori
parent 32ed26808d
commit 7536ee4bc3
7 changed files with 591 additions and 21 deletions

View file

@ -99,6 +99,9 @@ typedef struct VncDisplay VncDisplay;
#ifdef CONFIG_VNC_SASL
#include "vnc-auth-sasl.h"
#endif
#ifdef CONFIG_VNC_WS
#include "vnc-ws.h"
#endif
struct VncRectStat
{
@ -142,6 +145,11 @@ struct VncDisplay
QEMUTimer *timer;
int timer_interval;
int lsock;
#ifdef CONFIG_VNC_WS
int lwebsock;
bool websocket;
char *ws_display;
#endif
DisplayState *ds;
kbd_layout_t *kbd_layout;
int lock_key_sync;
@ -269,11 +277,19 @@ struct VncState
#ifdef CONFIG_VNC_SASL
VncStateSASL sasl;
#endif
#ifdef CONFIG_VNC_WS
bool encode_ws;
bool websocket;
#endif
QObject *info;
Buffer output;
Buffer input;
#ifdef CONFIG_VNC_WS
Buffer ws_input;
Buffer ws_output;
#endif
/* current output mode information */
VncWritePixels *write_pixels;
PixelFormat client_pf;
@ -493,6 +509,8 @@ void vnc_write_u16(VncState *vs, uint16_t value);
void vnc_write_u8(VncState *vs, uint8_t value);
void vnc_flush(VncState *vs);
void vnc_read_when(VncState *vs, VncReadEvent *func, size_t expecting);
void vnc_disconnect_finish(VncState *vs);
void vnc_init_state(VncState *vs);
/* Buffer I/O functions */
@ -511,6 +529,7 @@ void buffer_reset(Buffer *buffer);
void buffer_free(Buffer *buffer);
void buffer_append(Buffer *buffer, const void *data, size_t len);
void buffer_advance(Buffer *buf, size_t len);
uint8_t *buffer_end(Buffer *buffer);
/* Misc helpers */