qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Lieven <pl@kamp.de>
To: qemu-devel@nongnu.org
Cc: Peter Lieven <pl@kamp.de>, kraxel@redhat.com
Subject: [Qemu-devel] [PATCH 4/4] vnc: destroy server surface if no client is connected
Date: Thu, 27 Aug 2015 12:18:54 +0200	[thread overview]
Message-ID: <1440670734-5616-5-git-send-email-pl@kamp.de> (raw)
In-Reply-To: <1440670734-5616-1-git-send-email-pl@kamp.de>

if no client is connected there is no need to keep the server
surface. Throw it away and replace it with a dummy surface to
save memory.

Signed-off-by: Peter Lieven <pl@kamp.de>
---
 ui/vnc.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 061e337..57f0e54 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -776,6 +776,11 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl,
 
     vnc_abort_display_jobs(vd);
 
+    /* if no client is connected use a dummy surface */
+    if (QTAILQ_EMPTY(&vd->clients)) {
+        surface = qemu_create_displaysurface(0, 0);
+    }
+
     /* server surface */
     qemu_pixman_image_unref(vd->server);
     vd->ds = surface;
@@ -1263,6 +1268,9 @@ void vnc_disconnect_finish(VncState *vs)
 
     if (vs->initialized) {
         QTAILQ_REMOVE(&vs->vd->clients, vs, next);
+        if (QTAILQ_EMPTY(&vs->vd->clients)) {
+            vnc_dpy_switch(&vs->vd->dcl, NULL);
+        }
         qemu_remove_mouse_mode_change_notifier(&vs->mouse_mode_notifier);
     }
 
@@ -3083,6 +3091,7 @@ void vnc_init_state(VncState *vs)
 {
     vs->initialized = true;
     VncDisplay *vd = vs->vd;
+    bool first_client;
 
     vs->last_x = -1;
     vs->last_y = -1;
@@ -3095,9 +3104,15 @@ void vnc_init_state(VncState *vs)
     qemu_mutex_init(&vs->output_mutex);
     vs->bh = qemu_bh_new(vnc_jobs_bh, vs);
 
+    first_client = QTAILQ_EMPTY(&vd->clients);
     QTAILQ_INSERT_TAIL(&vd->clients, vs, next);
 
-    graphic_hw_update(vd->dcl.con);
+    if (first_client) {
+        /* set/restore the correct surface in the VNC server */
+        console_select(0);
+    } else {
+        graphic_hw_update(vd->dcl.con);
+    }
 
     vnc_write(vs, "RFB 003.008\n", 12);
     vnc_flush(vs);
-- 
1.9.1

  parent reply	other threads:[~2015-08-27 10:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-27 10:18 [Qemu-devel] [PATCH 0/4] VNC server memory savings Peter Lieven
2015-08-27 10:18 ` [Qemu-devel] [PATCH 1/4] vnc: make the Buffer capacity increase in powers of two Peter Lieven
2015-09-03  8:56   ` Gerd Hoffmann
2015-09-03 10:29     ` Peter Lieven
2015-09-03 10:47       ` Gerd Hoffmann
2015-08-27 10:18 ` [Qemu-devel] [PATCH 2/4] vnc: allow the Buffer to shrink again Peter Lieven
2015-08-27 10:39   ` Daniel P. Berrange
2015-08-27 12:36     ` Peter Lieven
2015-09-03  9:52     ` Gerd Hoffmann
2015-09-03 10:07       ` Peter Lieven
2015-09-03 11:52         ` Gerd Hoffmann
2015-09-03 14:52           ` Peter Lieven
2015-09-03 10:36       ` Peter Lieven
2015-09-03 11:57         ` Gerd Hoffmann
2015-09-03 12:00           ` Peter Lieven
2015-08-27 10:18 ` [Qemu-devel] [PATCH 3/4] vnc-jobs: move buffer_reset to vnc_async_encoding_end Peter Lieven
2015-08-27 10:18 ` Peter Lieven [this message]
2015-09-03  9:57   ` [Qemu-devel] [PATCH 4/4] vnc: destroy server surface if no client is connected Gerd Hoffmann
2015-09-03 10:08     ` Peter Lieven
2015-09-03 10:54       ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440670734-5616-5-git-send-email-pl@kamp.de \
    --to=pl@kamp.de \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).