qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 3/3] vnc: throttle screen updates.
@ 2009-03-18 16:09 Gerd Hoffmann
  2009-03-19 17:25 ` Stefano Stabellini
  0 siblings, 1 reply; 5+ messages in thread
From: Gerd Hoffmann @ 2009-03-18 16:09 UTC (permalink / raw)
  To: qemu-devel@nongnu.org

[-- Attachment #1: Type: text/plain, Size: 229 bytes --]

  Hi,

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.

cheers,
  Gerd

[-- Attachment #2: 0003-vnc-throttle-screen-updates.patch --]
[-- Type: text/plain, Size: 2592 bytes --]

>From e1a20de776afe0d108fa94b2170f6d5690f9a24c Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Mon, 16 Mar 2009 21:37:48 +0100
Subject: [PATCH 3/3] vnc: throttle screen updates.

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>
---
 vnc.c |   11 ++++++++++-
 vnc.h |    1 +
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/vnc.c b/vnc.c
index 0daaeac..8c60547 100644
--- a/vnc.c
+++ b/vnc.c
@@ -649,6 +649,7 @@ static void send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
 
 static void vnc_copy(VncState *vs, int src_x, int src_y, int dst_x, int dst_y, int w, int h)
 {
+    vs->force_update = 1;
     vnc_update_client(vs);
 
     vnc_write_u8(vs, 0);  /* msg id */
@@ -704,6 +705,12 @@ static void vnc_update_client(void *opaque)
 
         vga_hw_update();
 
+        if (vs->output.offset && !vs->audio_cap && !vs->force_update) {
+            /* kernel send buffers are full -> drop frames to throttle */
+            qemu_mod_timer(vs->timer, qemu_get_clock(rt_clock) + VNC_REFRESH_INTERVAL);
+            return;
+        }
+
         /*
          * Walk through the guest dirty map.
          * Check and copy modified bits from guest to server surface.
@@ -737,7 +744,7 @@ static void vnc_update_client(void *opaque)
             server_row += ds_get_linesize(vs->ds);
         }
 
-        if (!has_dirty && !vs->audio_cap) {
+        if (!has_dirty && !vs->audio_cap && !vs->force_update) {
             qemu_mod_timer(vs->timer, qemu_get_clock(rt_clock) + VNC_REFRESH_INTERVAL);
             return;
         }
@@ -781,6 +788,7 @@ static void vnc_update_client(void *opaque)
         vs->output.buffer[saved_offset] = (n_rectangles >> 8) & 0xFF;
         vs->output.buffer[saved_offset + 1] = n_rectangles & 0xFF;
         vnc_flush(vs);
+        vs->force_update = 0;
 
     }
 
@@ -1398,6 +1406,7 @@ static void framebuffer_update_request(VncState *vs, int incremental,
 
     int i;
     vs->need_update = 1;
+    vs->force_update = 1;
     if (!incremental) {
         for (i = 0; i < h; i++) {
             vnc_set_bits(vs->guest.dirty[y_position + i],
diff --git a/vnc.h b/vnc.h
index c00fb00..0a2c66c 100644
--- a/vnc.h
+++ b/vnc.h
@@ -121,6 +121,7 @@ struct VncState
 
     VncDisplay *vd;
     int need_update;
+    int force_update;
     uint32_t features;
     int absolute;
     int last_x;
-- 
1.6.1.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 0/3] vnc patches
@ 2009-03-20 11:31 Gerd Hoffmann
  2009-03-20 11:31 ` [Qemu-devel] [PATCH 3/3] vnc: throttle screen updates Gerd Hoffmann
  0 siblings, 1 reply; 5+ messages in thread
From: Gerd Hoffmann @ 2009-03-20 11:31 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

Respin of the vnc patches.  Changes:

 * Rebased to latest svn (adapted to display allocator changes).
 * Moved vga_hw_update() in patch #3 as suggested by Stefano Stabellini.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-03-20 11:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-18 16:09 [Qemu-devel] [PATCH 3/3] vnc: throttle screen updates Gerd Hoffmann
2009-03-19 17:25 ` Stefano Stabellini
2009-03-20  8:37   ` Gerd Hoffmann
2009-03-20 10:14     ` Stefano Stabellini
  -- strict thread matches above, loose matches on Subject: below --
2009-03-20 11:31 [Qemu-devel] [PATCH 0/3] vnc patches Gerd Hoffmann
2009-03-20 11:31 ` [Qemu-devel] [PATCH 3/3] vnc: throttle screen updates Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).