Skip to contentSkip to conversation

input patch queue

GIT PULL Applied Gerd Hoffmann 3 participants 10 messages Jun 4, 2014 – Sep 26, 2014

lore
Share & tools
lore
#0 lore raw

Hi,

This pull adds the keyboard delay support for the input layer and it updates the multiseat.txt doc file.

please pull,
Gerd

The following changes since commit e00fcfeab3d452cba3d0a08991a39ab15df66424:

Merge remote-tracking branch 'remotes/awilliam/tags/vfio-pci-for-qemu-20140602.0' into staging (2014-06-03 14:37:43 +0100)

are available in the git repository at:

git://git.kraxel.org/qemu tags/pull-input-10

for you to fetch changes up to 2082bac151f9ed17f4425a3dbe994ed0b7958c89:

docs/multiseat.txt: add note about spice (2014-06-04 08:40:42 +0200)

----------------------------------------------------------------
updates for docs/multiseat.txt
input: add support for kbd delays

----------------------------------------------------------------
Gerd Hoffmann (7):
input: add support for kbd delays
input: use kbd delays for send_key monitor command input/curses: add kbd delay between keydown and keyup events input/vnc: use kbd delays in press_key docs/multiseat.txt: use autoseat docs/multiseat.txt: gtk joined the party docs/multiseat.txt: add note about spice

 docs/multiseat.txt |  78 +++++++++++++++++++++++++-------------
 include/ui/input.h |   1 +
 ui/curses.c        |  10 +++++
 ui/input-legacy.c  |  45 +++-------------------
 ui/input.c         | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 ui/vnc.c           |   2 +
 6 files changed, 176 insertions(+), 68 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 5/7] docs/multiseat.txt: use autoseat

When using the autoseat feature of systemd/logind we'll only need a single udev rule for the pci bridge, which simplifies the guest setup a bit.

---
 docs/multiseat.txt | 54 +++++++++++++++++++++++++++++++-----------------------
 1 file changed, 31 insertions(+), 23 deletions(-)
docs/multiseat.txt +31 -23
index a6c71dd..126f39d 100644
@@ -46,29 +46,37 @@ You need a pretty recent linux guest.  systemd with loginctl.  kernel
 fully updated for the new kernel though, i.e. the live iso doesn't cut
 it.
 
-Now we'll have to configure the guest.  Boot and login.  By default
-all devices belong to seat0.  You can use "loginctl seat-status seat0"
-to list them all (and to get the sysfs paths for cut+paste).  Now
-we'll go assign all pci devices connected the pci bridge in slot 12 to
-a new head:
-
-loginctl attach seat-qemu \
-	 /sys/devices/pci0000:00/0000:00:12.0/0000:01:02.0/drm/card1
-loginctl attach seat-qemu \
-	 /sys/devices/pci0000:00/0000:00:12.0/0000:01:02.0/graphics/fb1
-loginctl attach seat-qemu \
-	 /sys/devices/pci0000:00/0000:00:12.0/0000:01:0f.0/usb2
-
-Use "loginctl seat-status seat-qemu" to check the result.  It isn't
-needed to assign the usb devices to the head individually, assigning a
-usb (root) hub will automatically assign all usb devices connected to
-it too.
-
-BTW: loginctl writes udev rules to /etc/udev/rules.d to make these
-device assignments permanent, so you need to do this only once.
-
-Now simply restart gdm (rebooting will do too), and a login screen
-should show up on the second head.
+Now we'll have to configure the guest.  Boot and login.  "lspci -vt"
+should list the pci bridge with the display adapter and usb controller:
+
+    [root@fedora ~]# lspci -vt
+    -[0000:00]-+-00.0  Intel Corporation 440FX - 82441FX PMC [Natoma]
+               [ ... ]
+               \-12.0-[01]--+-02.0  Device 1234:1111
+                            \-0f.0  NEC Corporation USB 3.0 Host Controller
+
+Good.  Now lets tell the system that the pci bridge and all devices
+below it belong to a separate seat by dropping a file into
+/etc/udev/rules.d:
+
+    [root@fedora ~]# cat /etc/udev/rules.d/70-qemu-autoseat.rules
+    SUBSYSTEMS=="pci", DEVPATH=="*/0000:00:12.0", TAG+="seat", ENV{ID_AUTOSEAT}="1"
+
+Reboot.  System should come up with two seats.  With loginctl you can
+check the configuration:
+
+    [root@fedora ~]# loginctl list-seats
+    SEAT
+    seat0
+    seat-pci-pci-0000_00_12_0
+
+    2 seats listed.
+
+You can use "loginctl seat-status seat-pci-pci-0000_00_12_0" to list
+the devices attached to the seat.
+
+Background info is here:
+  http://www.freedesktop.org/wiki/Software/systemd/multiseat/
 
 Enjoy!
 
Signature · 1 line
1.8.3.1
#2 lore raw

[Qemu-devel] [PULL 3/7] input/curses: add kbd delay between keydown and keyup events

In reply to Gerd Hoffmann
---
 ui/curses.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
ui/curses.c +10 -0
index de85f76..8edb038 100644
@@ -277,31 +277,41 @@ static void curses_refresh(DisplayChangeListener *dcl)
              * events, we need to emit both for each key received */
             if (keycode & SHIFT) {
                 qemu_input_event_send_key_number(NULL, SHIFT_CODE, true);
+                qemu_input_event_send_key_delay(0);
             }
             if (keycode & CNTRL) {
                 qemu_input_event_send_key_number(NULL, CNTRL_CODE, true);
+                qemu_input_event_send_key_delay(0);
             }
             if (keycode & ALT) {
                 qemu_input_event_send_key_number(NULL, ALT_CODE, true);
+                qemu_input_event_send_key_delay(0);
             }
             if (keycode & ALTGR) {
                 qemu_input_event_send_key_number(NULL, GREY | ALT_CODE, true);
+                qemu_input_event_send_key_delay(0);
             }
 
             qemu_input_event_send_key_number(NULL, keycode & KEY_MASK, true);
+            qemu_input_event_send_key_delay(0);
             qemu_input_event_send_key_number(NULL, keycode & KEY_MASK, false);
+            qemu_input_event_send_key_delay(0);
 
             if (keycode & ALTGR) {
                 qemu_input_event_send_key_number(NULL, GREY | ALT_CODE, false);
+                qemu_input_event_send_key_delay(0);
             }
             if (keycode & ALT) {
                 qemu_input_event_send_key_number(NULL, ALT_CODE, false);
+                qemu_input_event_send_key_delay(0);
             }
             if (keycode & CNTRL) {
                 qemu_input_event_send_key_number(NULL, CNTRL_CODE, false);
+                qemu_input_event_send_key_delay(0);
             }
             if (keycode & SHIFT) {
                 qemu_input_event_send_key_number(NULL, SHIFT_CODE, false);
+                qemu_input_event_send_key_delay(0);
             }
         } else {
             keysym = curses2qemu[chr];
Signature · 1 line
1.8.3.1
#3 lore raw

[Qemu-devel] [PULL 4/7] input/vnc: use kbd delays in press_key

In reply to Gerd Hoffmann
---
 ui/vnc.c | 2 ++
 1 file changed, 2 insertions(+)
ui/vnc.c +2 -0
index 61b1f93..1684206 100644
@@ -1553,7 +1553,9 @@ static void press_key(VncState *vs, int keysym)
 {
     int keycode = keysym2scancode(vs->vd->kbd_layout, keysym) & SCANCODE_KEYMASK;
     qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, true);
+    qemu_input_event_send_key_delay(0);
     qemu_input_event_send_key_number(vs->vd->dcl.con, keycode, false);
+    qemu_input_event_send_key_delay(0);
 }
 
 static int current_led_state(VncState *vs)
Signature · 1 line
1.8.3.1
#4 lore raw

[Qemu-devel] [PULL 1/7] input: add support for kbd delays

In reply to Gerd Hoffmann
---
 include/ui/input.h |   1 +
 ui/input.c         | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 106 insertions(+), 3 deletions(-)
include/ui/input.h +1 -0
index aa99b0c..5d5ac00 100644
@@ -39,6 +39,7 @@ InputEvent *qemu_input_event_new_key(KeyValue *key, bool down);
 void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down);
 void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down);
 void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down);
+void qemu_input_event_send_key_delay(uint32_t delay_ms);
 int qemu_input_key_number_to_qcode(uint8_t nr);
 int qemu_input_key_value_to_number(const KeyValue *value);
 int qemu_input_key_value_to_qcode(const KeyValue *value);
ui/input.c +105 -3

137 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#5 lore raw

[Qemu-devel] [PULL 2/7] input: use kbd delays for send_key monitor command

In reply to Gerd Hoffmann
---
 ui/input-legacy.c | 45 ++++++---------------------------------------
 1 file changed, 6 insertions(+), 39 deletions(-)
ui/input-legacy.c +6 -39
index 2a53860..3025f50 100644
@@ -74,27 +74,6 @@ int index_from_key(const char *key)
     return i;
 }
 
-static KeyValue **keyvalues;
-static int keyvalues_size;
-static QEMUTimer *key_timer;
-
-static void free_keyvalues(void)
-{
-    g_free(keyvalues);
-    keyvalues = NULL;
-    keyvalues_size = 0;
-}
-
-static void release_keys(void *opaque)
-{
-    while (keyvalues_size > 0) {
-        qemu_input_event_send_key(NULL, keyvalues[--keyvalues_size],
-                                  false);
-    }
-
-    free_keyvalues();
-}
-
 static KeyValue *copy_key_value(KeyValue *src)
 {
     KeyValue *dst = g_new(KeyValue, 1);
@@ -107,30 +86,18 @@ void qmp_send_key(KeyValueList *keys, bool has_hold_time, int64_t hold_time,
 {
     KeyValueList *p;
 
-    if (!key_timer) {
-        key_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, release_keys, NULL);
-    }
-
-    if (keyvalues != NULL) {
-        timer_del(key_timer);
-        release_keys(NULL);
-    }
-
     if (!has_hold_time) {
-        hold_time = 100;
+        hold_time = 0; /* use default */
     }
 
     for (p = keys; p != NULL; p = p->next) {
         qemu_input_event_send_key(NULL, copy_key_value(p->value), true);
-
-        keyvalues = g_realloc(keyvalues, sizeof(KeyValue *) *
-                              (keyvalues_size + 1));
-        keyvalues[keyvalues_size++] = copy_key_value(p->value);
+        qemu_input_event_send_key_delay(hold_time);
+    }
+    for (p = keys; p != NULL; p = p->next) {
+        qemu_input_event_send_key(NULL, copy_key_value(p->value), false);
+        qemu_input_event_send_key_delay(hold_time);
     }
-
-    /* delayed key up events */
-    timer_mod(key_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
-              muldiv64(get_ticks_per_sec(), hold_time, 1000));
 }
 
 static void legacy_kbd_event(DeviceState *dev, QemuConsole *src,
Signature · 1 line
1.8.3.1
#6 lore raw

Re: [Qemu-devel] [PULL 2/7] input: use kbd delays for send_key monitor command

Quoted 54 lines · Gerd Hoffmann
---
 ui/input-legacy.c | 45 ++++++---------------------------------------
 1 file changed, 6 insertions(+), 39 deletions(-)
ui/input-legacy.c +1 -31
index 2a53860..3025f50 100644
@@ -74,27 +74,6 @@ int index_from_key(const char *key)
     return i;
 }
 
-static KeyValue **keyvalues;
-static int keyvalues_size;
-static QEMUTimer *key_timer;
-
-static void free_keyvalues(void)
-{
-    g_free(keyvalues);
-    keyvalues = NULL;
-    keyvalues_size = 0;
-}
-
-static void release_keys(void *opaque)
-{
-    while (keyvalues_size > 0) {
-        qemu_input_event_send_key(NULL, keyvalues[--keyvalues_size],
-                                  false);
-    }
-
-    free_keyvalues();
-}
-
 static KeyValue *copy_key_value(KeyValue *src)
 {
     KeyValue *dst = g_new(KeyValue, 1);
@@ -107,30 +86,18 @@ void qmp_send_key(KeyValueList *keys, bool has_hold_time, int64_t hold_time,
 {
     KeyValueList *p;
 
-    if (!key_timer) {
-        key_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, release_keys, NULL);
-    }
-
-    if (keyvalues != NULL) {
-        timer_del(key_timer);
-        release_keys(NULL);
-    }
-
     if (!has_hold_time) {
-        hold_time = 100;
+        hold_time = 0; /* use default */
     }

ui/input-legacy.c void qmp_send_key(KeyValueList *keys, bool has_hold_time, int64_t hold_time, · line 97

Quoted 10 lines
ui/input-legacy.c +3 -4
 
     for (p = keys; p != NULL; p = p->next) {
         qemu_input_event_send_key(NULL, copy_key_value(p->value), true);
-
-        keyvalues = g_realloc(keyvalues, sizeof(KeyValue *) *
-                              (keyvalues_size + 1));
-        keyvalues[keyvalues_size++] = copy_key_value(p->value);
+        qemu_input_event_send_key_delay(hold_time);
+    }
+    for (p = keys; p != NULL; p = p->next) {

Hi Gerd,

This patch caused a regression, it changed the releasing order

When we send a serial keys together, the right order should be:

press key1
press key2
press key3

release key3
release key2
release key1

We can check the events by shokey command in Linux.

This regression will caused "sendkey Alt-Ctrl-Delete" doesn't work on some guests.

Thanks, Amos

Quoted 13 lines
ui/input-legacy.c +2 -4
+        qemu_input_event_send_key(NULL, copy_key_value(p->value), false);
+        qemu_input_event_send_key_delay(hold_time);
     }
-
-    /* delayed key up events */
-    timer_mod(key_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
-              muldiv64(get_ticks_per_sec(), hold_time, 1000));
 }
 
 static void legacy_kbd_event(DeviceState *dev, QemuConsole *src,
Signature · 1 line
1.8.3.1
Signature · 1 line
			Amos.
#7 lore raw

[Qemu-devel] [PULL 6/7] docs/multiseat.txt: gtk joined the party

In reply to Gerd Hoffmann
---
 docs/multiseat.txt | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
docs/multiseat.txt +13 -3
index 126f39d..dd3a831 100644
@@ -6,16 +6,20 @@ host side
 ---------
 
 First you must compile qemu with a user interface supporting
-multihead/multiseat and input event routing.  Right now this list is
-pretty short: sdl2.
+multihead/multiseat and input event routing.  Right now this
+list includes sdl2 and gtk (both 2+3):
 
   ./configure --enable-sdl --with-sdlabi=2.0
 
+or
+
+  ./configure --enable-gtk
+
 
 Next put together the qemu command line:
 
 qemu	-enable-kvm -usb $memory $disk $whatever \
-	-display sdl \
+	-display [ sdl | gtk ] \
 	-vga std \
 	-device usb-tablet
 
@@ -37,6 +41,12 @@ The "display=video2" sets up the input routing.  Any input coming from
 the window which belongs to the video.2 display adapter will be routed
 to these input devices.
 
+The sdl2 ui will start up with two windows, one for each display
+device.  The gtk ui will start with a single window and each display
+in a separate tab.  You can either simply switch tabs to switch heads,
+or use the "View / Detach tab" menu item to move one of the displays
+to its own window so you can see both display devices side-by-side.
+
 
 guest side
 ----------
Signature · 1 line
1.8.3.1
#8 lore raw

[Qemu-devel] [PULL 7/7] docs/multiseat.txt: add note about spice

In reply to Gerd Hoffmann
---
 docs/multiseat.txt | 8 ++++++++
 1 file changed, 8 insertions(+)
docs/multiseat.txt +8 -0
index dd3a831..67151e0 100644
@@ -47,6 +47,14 @@ in a separate tab.  You can either simply switch tabs to switch heads,
 or use the "View / Detach tab" menu item to move one of the displays
 to its own window so you can see both display devices side-by-side.
 
+Note on spice: Spice handles multihead just fine.  But it can't do
+multiseat.  For tablet events the event source is sent to the spice
+agent.  But qemu can't figure it, so it can't do input routing.
+Fixing this needs a new or extended input interface between
+libspice-server and qemu.  For keyboard events it is even worse:  The
+event source isn't included in the spice protocol, so the wire
+protocol must be extended to support this.
+
 
 guest side
 ----------
Signature · 1 line
1.8.3.1
#9 lore raw
In reply to Gerd Hoffmann
Quoted 12 lines · Gerd Hoffmann

Hi,

This pull adds the keyboard delay support for the input layer and it updates the multiseat.txt doc file.

please pull,
Gerd

The following changes since commit e00fcfeab3d452cba3d0a08991a39ab15df66424:

Merge remote-tracking branch 'remotes/awilliam/tags/vfio-pci-for-qemu-20140602.0' into staging (2014-06-03 14:37:43 +0100)

Quoted 8 lines

are available in the git repository at:

git://git.kraxel.org/qemu tags/pull-input-10

for you to fetch changes up to 2082bac151f9ed17f4425a3dbe994ed0b7958c89:

docs/multiseat.txt: add note about spice (2014-06-04 08:40:42 +0200)

Applied, thanks.

-- PMM