diff options
author | Corentin Chary <corentincj@iksaif.net> | 2010-07-07 20:58:02 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-07-26 17:36:14 -0500 |
commit | bd023f953e5e51237726af04300e4637fe203774 (patch) | |
tree | 5e7c71d3f68ed04d33ffc53a182c29cdbd8b5334 /ui/vnc.h | |
parent | 313b1d697d58f284f4490d135a652f8280c52e8a (diff) |
vnc: threaded VNC server
Implement a threaded VNC server using the producer-consumer model.
The main thread will push encoding jobs (a list a rectangles to update)
in a queue, and the VNC worker thread will consume that queue and send
framebuffer updates to the output buffer.
The threaded VNC server can be enabled with ./configure --enable-vnc-thread.
If you don't want it, just use ./configure --disable-vnc-thread and a syncrhonous
queue of job will be used (which as exactly the same behavior as the old queue).
If you disable the VNC thread, all thread related code will not be built and there will
be no overhead.
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'ui/vnc.h')
-rw-r--r-- | ui/vnc.h | 53 |
1 files changed, 52 insertions, 1 deletions
@@ -29,6 +29,9 @@ #include "qemu-common.h" #include "qemu-queue.h" +#ifdef CONFIG_VNC_THREAD +#include "qemu-thread.h" +#endif #include "console.h" #include "monitor.h" #include "audio/audio.h" @@ -59,6 +62,9 @@ typedef struct Buffer } Buffer; typedef struct VncState VncState; +typedef struct VncJob VncJob; +typedef struct VncRect VncRect; +typedef struct VncRectEntry VncRectEntry; typedef int VncReadEvent(VncState *vs, uint8_t *data, size_t len); @@ -101,6 +107,9 @@ struct VncDisplay DisplayState *ds; kbd_layout_t *kbd_layout; int lock_key_sync; +#ifdef CONFIG_VNC_THREAD + QemuMutex mutex; +#endif QEMUCursor *cursor; int cursor_msize; @@ -152,6 +161,37 @@ typedef struct VncZlib { int level; } VncZlib; +#ifdef CONFIG_VNC_THREAD +struct VncRect +{ + int x; + int y; + int w; + int h; +}; + +struct VncRectEntry +{ + struct VncRect rect; + QLIST_ENTRY(VncRectEntry) next; +}; + +struct VncJob +{ + VncState *vs; + + QLIST_HEAD(, VncRectEntry) rectangles; + QTAILQ_ENTRY(VncJob) next; +}; +#else +struct VncJob +{ + VncState *vs; + int rectangles; + size_t saved_offset; +}; +#endif + struct VncState { int csock; @@ -199,7 +239,16 @@ struct VncState uint8_t modifiers_state[256]; QEMUPutLEDEntry *led; - /* Encoding specific */ + bool abort; +#ifndef CONFIG_VNC_THREAD + VncJob job; +#else + QemuMutex output_mutex; +#endif + + /* Encoding specific, if you add something here, don't forget to + * update vnc_async_encoding_start() + */ VncTight tight; VncZlib zlib; VncHextile hextile; @@ -431,6 +480,8 @@ void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h, void vnc_convert_pixel(VncState *vs, uint8_t *buf, uint32_t v); /* Encodings */ +int vnc_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); + int vnc_raw_send_framebuffer_update(VncState *vs, int x, int y, int w, int h); int vnc_hextile_send_framebuffer_update(VncState *vs, int x, |