vnc: desktop size patches.
PATCH 1/5 vnc: factor out vnc_desktop_resize()
In reply to Gerd Hoffmann--- vnc.c | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-)
vnc.c +16 -8
@@ -514,6 +514,21 @@ void buffer_append(Buffer *buffer, const void *data, size_t len) buffer->offset += len; } +static void vnc_desktop_resize (VncState *vs) +{ +DisplayState *ds = vs->ds; + +if (vs->csock ==-1 || !vnc_has_feature (vs,VNC_FEATURE_RESIZE )) { +return ; + } +vnc_write_u8 (vs,VNC_MSG_SERVER_FRAMEBUFFER_UPDATE ); +vnc_write_u8 (vs,0 ); +vnc_write_u16 (vs,1 );/* number of rects */ +vnc_framebuffer_update (vs,0 ,0 ,ds_get_width (ds),ds_get_height (ds), +VNC_ENCODING_DESKTOPRESIZE ); +vnc_flush (vs); +} +static void vnc_dpy_resize (DisplayState *ds) {int size_changed;
@@ -542,14 +557,7 @@ static void vnc_dpy_resize(DisplayState *ds) QTAILQ_FOREACH(vs, &vd->clients, next) {vnc_colordepth (vs);if (size_changed) { -if (vs->csock !=-1 &&vnc_has_feature (vs,VNC_FEATURE_RESIZE )) { -vnc_write_u8 (vs,VNC_MSG_SERVER_FRAMEBUFFER_UPDATE ); -vnc_write_u8 (vs,0 ); -vnc_write_u16 (vs,1 );/* number of rects */ -vnc_framebuffer_update (vs,0 ,0 ,ds_get_width (ds),ds_get_height (ds), -VNC_ENCODING_DESKTOPRESIZE ); -vnc_flush (vs); - } +vnc_desktop_resize (vs); }if (vs->vd->cursor) {vnc_cursor_define (vs);
Signature · 1 line
1.6.6.1
PATCH 2/5 vnc: send desktopresize event as reply to set encodings
In reply to Gerd HoffmannIn case the desktop did resize while the vnc connection setup was still in progress the client isn't informed about it. Send a desktop resize event as soon as the client told us it can handle deskop resize via set encodings message to make sure the client us up to date.
--- vnc.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
vnc.c +1 -0
@@ -1709,6 +1709,7 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings)break ; } } +vnc_desktop_resize (vs);check_pointer_type_change (&vs->mouse_mode_notifier); }
Signature · 1 line
1.6.6.1
PATCH 3/5 vnc: keep track of client desktop size
In reply to Gerd HoffmannAdd two new variables to keep track of the vnc clients desktop size.
--- vnc.c | 10 +++++++--- vnc.h | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-)
vnc.c +7 -3
@@ -521,10 +521,12 @@ static void vnc_desktop_resize(VncState *vs)if (vs->csock ==-1 || !vnc_has_feature (vs,VNC_FEATURE_RESIZE )) {return ; } + vs->client_width =ds_get_width (ds); + vs->client_height =ds_get_height (ds);vnc_write_u8 (vs,VNC_MSG_SERVER_FRAMEBUFFER_UPDATE );vnc_write_u8 (vs,0 );vnc_write_u16 (vs,1 );/* number of rects */ -vnc_framebuffer_update (vs,0 ,0 ,ds_get_width (ds),ds_get_height (ds), +vnc_framebuffer_update (vs,0 ,0 , vs->client_width, vs->client_height,VNC_ENCODING_DESKTOPRESIZE );vnc_flush (vs); }
@@ -1958,8 +1960,10 @@ static int protocol_client_init(VncState *vs, uint8_t *data, size_t len)char buf[1024 ];int size; -vnc_write_u16 (vs,ds_get_width (vs->ds)); -vnc_write_u16 (vs,ds_get_height (vs->ds)); + vs->client_width =ds_get_width (vs->ds); + vs->client_height =ds_get_height (vs->ds); +vnc_write_u16 (vs, vs->client_width); +vnc_write_u16 (vs, vs->client_height);pixel_format_message (vs);
vnc.h +2 -0
@@ -134,6 +134,8 @@ struct VncStateint absolute;int last_x;int last_y; +int client_width; +int client_height;uint32_t vnc_encoding;
Signature · 1 line
1.6.6.1
PATCH 4/5 vnc: don't send invalid screen updates.
In reply to Gerd HoffmannDon't send updates for screen areas which are outside the clients desktop. May happed with vnc clients which don't support the desktop resize message.
--- vnc.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
vnc.c +6 -2
@@ -836,6 +836,7 @@ static int vnc_update_client(VncState *vs, int has_dirty)int y;int n_rectangles;int saved_offset; +int width, height;if (vs->output.offset && !vs->audio_cap && !vs->force_update)/* kernel send buffers are full -> drop frames to throttle */
@@ -856,10 +857,13 @@ static int vnc_update_client(VncState *vs, int has_dirty) saved_offset = vs->output.offset;vnc_write_u16 (vs,0 ); -for (y =0 ; y < vd->server->height; y++) { + width =MIN (vd->server->width, vs->client_width); + height =MIN (vd->server->height, vs->client_height); + +for (y =0 ; y < height; y++) {int x;int last_x =-1 ; -for (x =0 ; x < vd->server->width /16 ; x++) { +for (x =0 ; x < width /16 ; x++) {if (vnc_get_bit (vs->dirty[y], x)) {if (last_x ==-1 ) { last_x = x;
Signature · 1 line
1.6.6.1
PATCH 5/5 vnc: move size-changed check into the vnc_desktop_resize function.
In reply to Gerd HoffmannThis make sure we send a desktop resize message only in case we actually have to, using the new variables which track the clients desktop size.
--- vnc.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)
vnc.c +5 -6
@@ -521,6 +521,10 @@ static void vnc_desktop_resize(VncState *vs)if (vs->csock ==-1 || !vnc_has_feature (vs,VNC_FEATURE_RESIZE )) {return ; } +if (vs->client_width ==ds_get_width (ds) && + vs->client_height ==ds_get_height (ds)) { +return ; + } vs->client_width =ds_get_width (ds); vs->client_height =ds_get_height (ds);vnc_write_u8 (vs,VNC_MSG_SERVER_FRAMEBUFFER_UPDATE );
@@ -533,7 +537,6 @@ static void vnc_desktop_resize(VncState *vs)static void vnc_dpy_resize (DisplayState *ds) { -int size_changed;VncDisplay *vd = ds->opaque;VncState *vs;
@@ -551,16 +554,12 @@ static void vnc_dpy_resize(DisplayState *ds) vd->guest.ds =qemu_mallocz (sizeof (*vd->guest.ds));if (ds_get_bytes_per_pixel (ds) != vd->guest.ds->pf.bytes_per_pixel)console_color_init (ds); - size_changed =ds_get_width (ds) != vd->guest.ds->width || -ds_get_height (ds) != vd->guest.ds->height; *(vd->guest.ds) = *(ds->surface);memset (vd->guest.dirty,0xFF ,sizeof (vd->guest.dirty)); QTAILQ_FOREACH(vs, &vd->clients, next) {vnc_colordepth (vs); -if (size_changed) { -vnc_desktop_resize (vs); - } +vnc_desktop_resize (vs);if (vs->vd->cursor) {vnc_cursor_define (vs); }
Signature · 1 line
1.6.6.1
cover vnc: desktop size patches.
Hi,
This series brings a bunch of vnc desktop size patches, fixing the issues discussed in the "Possible race condition in VNC display resizing" thread. Check list archive here:
http://lists.gnu.org/archive/html/qemu-devel/2010-04/msg01778.html
cheers,
Gerd
Gerd Hoffmann (5):
vnc: factor out vnc_desktop_resize()
vnc: send desktopresize event as reply to set encodings
vnc: keep track of client desktop size
vnc: don't send invalid screen updates.
vnc: move size-changed check into the vnc_desktop_resize function.
vnc.c | 50 +++++++++++++++++++++++++++++++++----------------- vnc.h | 2 ++ 2 files changed, 35 insertions(+), 17 deletions(-)
Re: [Qemu-devel] [PATCH 2/5] vnc: send desktopresize event as reply to set encodings
In reply to Gerd HoffmannQuoted 4 lines · Gerd Hoffmann
In case the desktop did resize while the vnc connection setup was still in progress the client isn't informed about it. Send a desktop resize event as soon as the client told us it can handle deskop resize via set encodings message to make sure the client us up to date.
I had a similar patch on my queue but yours is probably cleaner :).
Signature · 2 lines
Corentin Chary http://xf.iksaif.net
Quoted 18 lines · Gerd Hoffmann
Hi,
This series brings a bunch of vnc desktop size patches, fixing the issues discussed in the "Possible race condition in VNC display resizing" thread. Check list archive here:
http://lists.gnu.org/archive/html/qemu-devel/2010-04/msg01778.html
cheers,
GerdGerd Hoffmann (5):
vnc: factor outvnc_desktop_resize()
vnc: send desktopresize event as reply to set encodings
vnc: keep track of client desktop size
vnc: don't send invalid screen updates.
vnc: move size-changed check into thevnc_desktop_resizefunction.
Quoted 3 lines
vnc.c | 50 +++++++++++++++++++++++++++++++++----------------- vnc.h | 2 ++ 2 files changed, 35 insertions(+), 17 deletions(-)
ACK, these patches look good for solving both of the problems I encountered (the resize race + the out-of-bounds updates) in that quoted thread.
Daniel
Signature · 4 lines
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
Anthony Liguori
AppliedRe: [Qemu-devel] [PATCH 1/5] vnc: factor out vnc_desktop_resize()
In reply to Gerd HoffmannQuoted 2 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann<[email protected]>
Applied all. Thanks.
Regards,
Anthony Liguori
Quoted 47 lines
--- vnc.c | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-)vnc.c +16
-8@@ -514,6 +514,21 @@ void buffer_append(Buffer *buffer, const void *data, size_t len) buffer->offset += len; } +static void vnc_desktop_resize (VncState *vs) +{ +DisplayState *ds = vs->ds; + +if (vs->csock ==-1 || !vnc_has_feature (vs,VNC_FEATURE_RESIZE )) { +return ; + } +vnc_write_u8 (vs,VNC_MSG_SERVER_FRAMEBUFFER_UPDATE ); +vnc_write_u8 (vs,0 ); +vnc_write_u16 (vs,1 );/* number of rects */ +vnc_framebuffer_update (vs,0 ,0 ,ds_get_width (ds),ds_get_height (ds), +VNC_ENCODING_DESKTOPRESIZE ); +vnc_flush (vs); +} +static void vnc_dpy_resize (DisplayState *ds) {int size_changed;@@ -542,14 +557,7 @@ static void vnc_dpy_resize(DisplayState *ds) QTAILQ_FOREACH(vs,&vd->clients, next) {vnc_colordepth (vs);if (size_changed) { -if (vs->csock !=-1 &&vnc_has_feature (vs,VNC_FEATURE_RESIZE )) { -vnc_write_u8 (vs,VNC_MSG_SERVER_FRAMEBUFFER_UPDATE ); -vnc_write_u8 (vs,0 ); -vnc_write_u16 (vs,1 );/* number of rects */ -vnc_framebuffer_update (vs,0 ,0 ,ds_get_width (ds),ds_get_height (ds), -VNC_ENCODING_DESKTOPRESIZE ); -vnc_flush (vs); - } +vnc_desktop_resize (vs); }if (vs->vd->cursor) {vnc_cursor_define (vs);