Commit c522d0e2dee3774884a731691a702126901a1a88

Authored by aliguori
1 parent 23decc87

vnc: throttle screen updates. (Gerd Hoffmann)

This patch makes the vnc server code skip screen refreshes in case
there is data in the output buffer.  This reduces the refresh rate to
throttle the bandwidth needed in case the network link is saturated.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6862 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 11 additions and 1 deletions
... ... @@ -657,6 +657,7 @@ static void send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
657 657  
658 658 static void vnc_copy(VncState *vs, int src_x, int src_y, int dst_x, int dst_y, int w, int h)
659 659 {
  660 + vs->force_update = 1;
660 661 vnc_update_client(vs);
661 662  
662 663 vnc_write_u8(vs, 0); /* msg id */
... ... @@ -710,6 +711,12 @@ static void vnc_update_client(void *opaque)
710 711 int saved_offset;
711 712 int has_dirty = 0;
712 713  
  714 + if (vs->output.offset && !vs->audio_cap && !vs->force_update) {
  715 + /* kernel send buffers are full -> drop frames to throttle */
  716 + qemu_mod_timer(vs->timer, qemu_get_clock(rt_clock) + VNC_REFRESH_INTERVAL);
  717 + return;
  718 + }
  719 +
713 720 vga_hw_update();
714 721  
715 722 /*
... ... @@ -745,7 +752,7 @@ static void vnc_update_client(void *opaque)
745 752 server_row += ds_get_linesize(vs->ds);
746 753 }
747 754  
748   - if (!has_dirty && !vs->audio_cap) {
  755 + if (!has_dirty && !vs->audio_cap && !vs->force_update) {
749 756 qemu_mod_timer(vs->timer, qemu_get_clock(rt_clock) + VNC_REFRESH_INTERVAL);
750 757 return;
751 758 }
... ... @@ -789,6 +796,7 @@ static void vnc_update_client(void *opaque)
789 796 vs->output.buffer[saved_offset] = (n_rectangles >> 8) & 0xFF;
790 797 vs->output.buffer[saved_offset + 1] = n_rectangles & 0xFF;
791 798 vnc_flush(vs);
  799 + vs->force_update = 0;
792 800  
793 801 }
794 802  
... ... @@ -1407,6 +1415,7 @@ static void framebuffer_update_request(VncState *vs, int incremental,
1407 1415  
1408 1416 int i;
1409 1417 vs->need_update = 1;
  1418 + vs->force_update = 1;
1410 1419 if (!incremental) {
1411 1420 for (i = 0; i < h; i++) {
1412 1421 vnc_set_bits(vs->guest.dirty[y_position + i],
... ...
... ... @@ -121,6 +121,7 @@ struct VncState
121 121  
122 122 VncDisplay *vd;
123 123 int need_update;
  124 + int force_update;
124 125 uint32_t features;
125 126 int absolute;
126 127 int last_x;
... ...