Skip to contentSkip to conversation

vnc patch collection

PATCH New Gerd Hoffmann 1 participant 4 messages Jan 20, 2012

lore
Share & tools
lore
#0 lore raw

cover vnc patch collection

Hi,

All of these patches have been on the list before, this is just a re-post after rebasing them. This time with a git repo to pull from for your convinience. Check the individual patch descriptions for details.

cheers,
Gerd

The following changes since commit 515689235c4c3d9c3f0406ddcdd21ed8da77062b:

Merge remote-tracking branch 'spice/spice.v47' into staging (2012-01-19 12:51:02 -0600)

are available in the git repository at:

git://git.kraxel.org/qemu vnc.1

Gerd Hoffmann (3):
Fix vnc memory corruption with width = 1400
vnc: fix ctrl key in vnc terminal emulation
vnc: implement shared flag handling.

 qemu-options.hx |   13 ++++++
 ui/vnc.c        |  110 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 ui/vnc.h        |   16 ++++++++
 3 files changed, 136 insertions(+), 3 deletions(-)
#1 lore raw

PATCH 1/3 Fix vnc memory corruption with width = 1400

vnc assumes that the screen width is a multiple of 16 in several places. If this is not the case vnc will overrun buffers, corrupt memory, make qemu crash.

This is the minimum fix for this bug. It makes sure we don't overrun the scanline, thereby fixing the segfault. The rendering is *not* correct though, there is a black border at the right side of the screen, 8 pixels wide because 1400 % 16 == 8.

---
 ui/vnc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
ui/vnc.c +1 -1
index 16b79ec..5752bf8 100644
@@ -2445,7 +2445,7 @@ static int vnc_refresh_server_surface(VncDisplay *vd)
             guest_ptr  = guest_row;
             server_ptr = server_row;
 
-            for (x = 0; x < vd->guest.ds->width;
+            for (x = 0; x + 15 < vd->guest.ds->width;
                     x += 16, guest_ptr += cmp_bytes, server_ptr += cmp_bytes) {
                 if (!test_and_clear_bit((x / 16), vd->guest.dirty[y]))
                     continue;
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/3 vnc: fix ctrl key in vnc terminal emulation

In reply to Gerd Hoffmann

Make the control keys for terminals on the vnc display (i.e. qemu -vnc :0 -serial vc) work. Makes the terminals alot more usable as typing Ctrl-C in your serial console actually has the desired effect ;)

---
 ui/vnc.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
ui/vnc.c +8 -2
index 5752bf8..810582b 100644
@@ -1552,9 +1552,11 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym)
         else
             kbd_put_keycode(keycode | SCANCODE_UP);
     } else {
+        bool numlock = vs->modifiers_state[0x45];
+        bool control = (vs->modifiers_state[0x1d] ||
+                        vs->modifiers_state[0x9d]);
         /* QEMU console emulation */
         if (down) {
-            int numlock = vs->modifiers_state[0x45];
             switch (keycode) {
             case 0x2a:                          /* Left Shift */
             case 0x36:                          /* Right Shift */
@@ -1642,7 +1644,11 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym)
                 break;
 
             default:
-                kbd_put_keysym(sym);
+                if (control) {
+                    kbd_put_keysym(sym & 0x1f);
+                } else {
+                    kbd_put_keysym(sym);
+                }
                 break;
             }
         }
Signature · 1 line
1.7.1
#3 lore raw

PATCH 3/3 vnc: implement shared flag handling.

In reply to Gerd Hoffmann

VNC clients send a shared flag in the client init message. Up to now qemu completely ignores this. This patch implements shared flag handling. It comes with three policies: By default qemu behaves as one would expect: Asking for a exclusive access grants exclusive access to the client connecting. There is also a desktop sharing mode which disallows exclusive connects (so one forgetting -shared wouldn't drop everybody else) and a compatibility mode which mimics the traditional (but non-conforming) qemu behavior.

---
 qemu-options.hx |   13 +++++++
 ui/vnc.c        |   98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 ui/vnc.h        |   16 +++++++++
 3 files changed, 127 insertions(+), 0 deletions(-)
qemu-options.hx +13 -0
index 6295cde..6317660 100644
@@ -1090,6 +1090,19 @@ This can be really helpful to save bandwidth when playing videos. Disabling
 adaptive encodings allows to restore the original static behavior of encodings
 like Tight.
 
+@item share=[allow-exclusive|force-shared|ignore]
+
+Set display sharing policy.  'allow-exclusive' allows clients to ask
+for exclusive access.  As suggested by the rfb spec this is
+implemented by dropping other connections.  Connecting multiple
+clients in parallel requires all clients asking for a shared session
+(vncviewer: -shared switch).  This is the default.  'force-shared'
+disables exclusive client access.  Useful for shared desktop sessions,
+where you don't want someone forgetting specify -shared disconnect
+everybody else.  'ignore' completely ignores the shared flag and
+allows everybody connect unconditionally.  Doesn't conform to the rfb
+spec but is traditional qemu behavior.
+
 @end table
 ETEXI
 
ui/vnc.c +98 -0

136 lines not on this page · raw message

ui/vnc.h +16 -0
index 66689f1..0bd1fc6 100644
@@ -122,9 +122,24 @@ struct VncSurface
     DisplaySurface *ds;
 };
 
+typedef enum VncShareMode {
+    VNC_SHARE_MODE_CONNECTING = 1,
+    VNC_SHARE_MODE_SHARED,
+    VNC_SHARE_MODE_EXCLUSIVE,
+    VNC_SHARE_MODE_DISCONNECTED,
+} VncShareMode;
+
+typedef enum VncSharePolicy {
+    VNC_SHARE_POLICY_IGNORE = 1,
+    VNC_SHARE_POLICY_ALLOW_EXCLUSIVE,
+    VNC_SHARE_POLICY_FORCE_SHARED,
+} VncSharePolicy;
+
 struct VncDisplay
 {
     QTAILQ_HEAD(, VncState) clients;
+    int num_exclusive;
+    VncSharePolicy share_policy;
     QEMUTimer *timer;
     int timer_interval;
     int lsock;
@@ -250,6 +265,7 @@ struct VncState
     int last_y;
     int client_width;
     int client_height;
+    VncShareMode share_mode;
 
     uint32_t vnc_encoding;
 
Signature · 1 line
1.7.1