Blame SOURCES/kvm-vnc-only-alloc-server-surface-with-clients-connected.patch

5d360b
From e7fa743d920c9c201bcf1e42e2c0058249a5c1e5 Mon Sep 17 00:00:00 2001
5d360b
From: "Daniel P. Berrange" <berrange@redhat.com>
5d360b
Date: Thu, 8 Feb 2018 17:50:27 +0100
5d360b
Subject: [PATCH 13/27] vnc: only alloc server surface with clients connected
5d360b
5d360b
RH-Author: Daniel P. Berrange <berrange@redhat.com>
5d360b
Message-id: <20180208175041.5634-14-berrange@redhat.com>
5d360b
Patchwork-id: 78956
5d360b
O-Subject: [RHEL-7.5 qemu-kvm PATCH v1 13/27] vnc: only alloc server surface with clients connected
5d360b
Bugzilla: 1527405
5d360b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
5d360b
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
5d360b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
5d360b
From: Gerd Hoffmann <kraxel@redhat.com>
5d360b
5d360b
RHEL-7 note: (a) the "graphic_hw_update(NULL)" call is different in the
5d360b
upstream context due to commit 1d0d59fe2919 ("vnc: allow binding servers
5d360b
to qemu consoles", 2015-01-22). That commit talks about "multiseat" and
5d360b
is part of v2.3.0, so out of scope for this backport. (b) The
5d360b
QTAILQ_INSERT_HEAD() macro invocation is QTAILQ_INSERT_TAIL() in the
5d360b
upstream context, due to commit e5f34cdd2da5 ("vnc: track &
5d360b
limit connections", 2015-01-22), part of v2.3.0. That commit is also
5d360b
irrelevant for this backport.
5d360b
5d360b
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
5d360b
Reviewed-by: Peter Lieven <pl@kamp.de>
5d360b
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
5d360b
Message-id: 1446203414-4013-15-git-send-email-kraxel@redhat.com
5d360b
(cherry picked from commit c7628bff4138ce906a3620d12e0820c1cf6c140d)
5d360b
5d360b
 Conflicts:
5d360b
	ui/vnc.c - context differences
5d360b
5d360b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
---
5d360b
 ui/vnc.c | 12 ++++++++++++
5d360b
 1 file changed, 12 insertions(+)
5d360b
5d360b
diff --git a/ui/vnc.c b/ui/vnc.c
5d360b
index df081a5..dc09089 100644
5d360b
--- a/ui/vnc.c
5d360b
+++ b/ui/vnc.c
5d360b
@@ -620,6 +620,10 @@ static void vnc_update_server_surface(VncDisplay *vd)
5d360b
     qemu_pixman_image_unref(vd->server);
5d360b
     vd->server = NULL;
5d360b
 
5d360b
+    if (QTAILQ_EMPTY(&vd->clients)) {
5d360b
+        return;
5d360b
+    }
5d360b
+
5d360b
     vd->server = pixman_image_create_bits(VNC_SERVER_FB_FORMAT,
5d360b
                                           vnc_width(vd),
5d360b
                                           vnc_height(vd),
5d360b
@@ -1019,6 +1023,10 @@ void vnc_disconnect_finish(VncState *vs)
5d360b
     if (vs->initialized) {
5d360b
         QTAILQ_REMOVE(&vs->vd->clients, vs, next);
5d360b
         qemu_remove_mouse_mode_change_notifier(&vs->mouse_mode_notifier);
5d360b
+        if (QTAILQ_EMPTY(&vs->vd->clients)) {
5d360b
+            /* last client gone */
5d360b
+            vnc_update_server_surface(vs->vd);
5d360b
+        }
5d360b
     }
5d360b
 
5d360b
     if (vs->vd->lock_key_sync)
5d360b
@@ -2819,6 +2827,7 @@ void vnc_init_state(VncState *vs)
5d360b
 {
5d360b
     vs->initialized = true;
5d360b
     VncDisplay *vd = vs->vd;
5d360b
+    bool first_client = QTAILQ_EMPTY(&vd->clients);
5d360b
 
5d360b
     vs->last_x = -1;
5d360b
     vs->last_y = -1;
5d360b
@@ -2832,6 +2841,9 @@ void vnc_init_state(VncState *vs)
5d360b
     vs->bh = qemu_bh_new(vnc_jobs_bh, vs);
5d360b
 
5d360b
     QTAILQ_INSERT_HEAD(&vd->clients, vs, next);
5d360b
+    if (first_client) {
5d360b
+        vnc_update_server_surface(vd);
5d360b
+    }
5d360b
 
5d360b
     graphic_hw_update(NULL);
5d360b
 
5d360b
-- 
5d360b
1.8.3.1
5d360b