input: add qemu_input_qcode_to_linux + qemu_input_linux_to_qcode
PATCH v2 1/3 input: add qemu_input_qcode_to_linux + qemu_input_linux_to_qcode
--- include/ui/input.h | 3 ++ ui/input-keymap.c | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+)
include/ui/input.h +3 -0
@@ -48,6 +48,9 @@ int qemu_input_key_value_to_qcode(const KeyValue *value);int qemu_input_key_value_to_scancode (const KeyValue *value,bool down,int *codes); +int qemu_input_qcode_to_linux (unsigned int qcode); +int qemu_input_linux_to_qcode (unsigned int lnx); +InputEvent *qemu_input_event_new_btn (InputButton btn,bool down);void qemu_input_queue_btn (QemuConsole *src,InputButton btn,bool down); void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
ui/input-keymap.c +145 -0
160 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 2/3 input: linux evdev support
This patch adds support for reading input events directly from linux evdev devices and forward them to the guest. Unlike virtio-input-host which simply passes on all events to the guest without looking at them this will interpret the events and feed them into the qemu input subsystem.
Therefore this is limited to what the qemu input subsystem and the emulated input devices are able to handle. Also there is no support for absolute coordinates (tablet/touchscreen). So we are talking here about basic mouse and keyboard support.
The advantage is that it'll work without virtio-input drivers in the guest, the events are delivered to the usual ps/2 or usb input devices (depending on what the machine happens to have). And for keyboards qemu is able to switch the keyboard between guest and host on hotkey. The hotkey is hard-coded for now (both control keys), initialy the guest owns the keyboard.
Probably most useful when assigning vga devices with vfio and using a physical monitor instead of vnc/spice/gtk as guest display.
Usage: Add '-input-linux /dev/input/event<nr>' to the qemu command line. Note that udev has rules which populate /dev/input/by-{id,path} with static names, which might be more convinient to use.
--- include/ui/input.h | 2 + qemu-options.hx | 9 +++ ui/Makefile.objs | 1 + ui/input-linux.c | 233 +++++++++++++++++++++++++++++++++++++++++++++++++++++ vl.c | 11 +++ 5 files changed, 256 insertions(+) create mode 100644 ui/input-linux.c
include/ui/input.h +2 -0
@@ -68,4 +68,6 @@ void qemu_input_check_mode_change(void);void qemu_add_mouse_mode_change_notifier (Notifier *notify);void qemu_remove_mouse_mode_change_notifier (Notifier *notify); +int input_linux_init (void *opaque,QemuOpts *opts,Error **errp); +#endif /* INPUT_H */
qemu-options.hx +9 -0
@@ -1165,6 +1165,15 @@ STEXI Set the initial graphical resolution and depth (PPC, SPARC only). ETEXI +DEF("input-linux", 1, QEMU_OPTION_input_linux, + "-input-linux <evdev>\n" + " Use input device.\n", QEMU_ARCH_ALL) +STEXI +@item -input-linux @var{dev} +@findex -input-linux +Use input device. +ETEXI + DEF("vnc", HAS_ARG, QEMU_OPTION_vnc , "-vnc display start a VNC server on display\n", QEMU_ARCH_ALL) STEXI
ui/Makefile.objs +1 -0
@@ -9,6 +9,7 @@ vnc-obj-y += vnc-jobs.o common-obj-y += keymaps.o console.o cursor.o qemu-pixman.o common-obj-y += input.o input-keymap.o input-legacy.o +common-obj-$(CONFIG_LINUX) += input-linux.o common-obj-$(CONFIG_SPICE) += spice-core.o spice-input.o spice-display.o common-obj-$(CONFIG_SDL) += sdl.mo x_keymap.o common-obj-$(CONFIG_COCOA) += cocoa.o
ui/input-linux.c new file +233 -0
233 lines not on this page · raw message
vl.c +11 -0
@@ -78,6 +78,7 @@ int main(int argc, char **argv)#include "net/slirp.h" #include "monitor/monitor.h" #include "ui/console.h" +#include "ui/input.h" #include "sysemu/sysemu.h" #include "sysemu/numa.h" #include "exec/gdbstub.h"
@@ -3742,6 +3743,12 @@ int main(int argc, char **argv, char **envp)#endif break ; } +case QEMU_OPTION_input_linux: +if (!qemu_opts_parse_noisily (qemu_find_opts ("input-linux" ), + optarg, true)) { +exit (1 ); + } +break ;case QEMU_OPTION_no_acpi: acpi_enabled =0 ;break ;
@@ -4622,6 +4629,10 @@ int main(int argc, char **argv, char **envp)qemu_spice_display_init (); }#endif +#ifdef CONFIG_LINUX +qemu_opts_foreach (qemu_find_opts ("input-linux" ), + input_linux_init,NULL , &error_fatal); +#endif if (foreach_device_config (DEV_GDB , gdbserver_start) <0 ) {exit (1 );
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [vfio-users] [PATCH v2 2/3] input: linux evdev support
So basically this remove the need for us to use synergy, how do we apply the patch to an existing config using libvirt?
2015-12-14 15:18 GMT+01:00 Gerd Hoffmann <[email protected]>:
Quoted 367 lines
This patch adds support for reading input events directly from linux evdev devices and forward them to the guest. Unlike virtio-input-host which simply passes on all events to the guest without looking at them this will interpret the events and feed them into the qemu input subsystem.
Therefore this is limited to what the qemu input subsystem and the emulated input devices are able to handle. Also there is no support for absolute coordinates (tablet/touchscreen). So we are talking here about basic mouse and keyboard support.
The advantage is that it'll work without virtio-input drivers in the guest, the events are delivered to the usual ps/2 or usb input devices (depending on what the machine happens to have). And for keyboards qemu is able to switch the keyboard between guest and host on hotkey. The hotkey is hard-coded for now (both control keys), initialy the guest owns the keyboard.
Probably most useful when assigning vga devices with vfio and using a physical monitor instead of vnc/spice/gtk as guest display.
Usage: Add '-input-linux /dev/input/event<nr>' to the qemu command line. Note that udev has rules which populate
/dev/input/by-{id,path}with static names, which might be more convinient to use.Signed-off-by Gerd Hoffmann <[email protected]>--- include/ui/input.h | 2 + qemu-options.hx | 9 +++ ui/Makefile.objs | 1 + ui/input-linux.c | 233 +++++++++++++++++++++++++++++++++++++++++++++++++++++ vl.c | 11 +++ 5 files changed, 256 insertions(+) create mode 100644 ui/input-linux.cinclude/ui/input.h +2
-0@@ -68,4 +68,6 @@ void qemu_input_check_mode_change(void);void qemu_add_mouse_mode_change_notifier (Notifier *notify);void qemu_remove_mouse_mode_change_notifier (Notifier *notify); +int input_linux_init (void *opaque,QemuOpts *opts,Error **errp); +#endif /* INPUT_H */ qemu-options.hx +9
-0@@ -1165,6 +1165,15 @@ STEXI Set the initial graphical resolution and depth (PPC, SPARC only). ETEXI +DEF("input-linux", 1, QEMU_OPTION_input_linux, + "-input-linux <evdev>\n" + " Use input device.\n", QEMU_ARCH_ALL) +STEXI +@item -input-linux @var{dev} +@findex -input-linux +Use input device. +ETEXI + DEF("vnc", HAS_ARG, QEMU_OPTION_vnc , "-vnc display start a VNC server on display\n", QEMU_ARCH_ALL) STEXIui/Makefile.objs +1
-0@@ -9,6 +9,7 @@ vnc-obj-y += vnc-jobs.o common-obj-y += keymaps.o console.o cursor.o qemu-pixman.o common-obj-y += input.o input-keymap.o input-legacy.o +common-obj-$(CONFIG_LINUX) += input-linux.o common-obj-$(CONFIG_SPICE) += spice-core.o spice-input.o spice-display.o common-obj-$(CONFIG_SDL) += sdl.mo x_keymap.o common-obj-$(CONFIG_COCOA) += cocoa.oui/input-linux.c new file +121
-0@@ -0,0 +1,233 @@ +/* +* This work is licensed under the terms of the GNU GPL, version 2 or +* (at your option) any later version. See the COPYING file in the +* top-level directory. +*/ + +#include "qemu-common.h" +#include "qemu/config-file.h" +#include "qemu/sockets.h" +#include "sysemu/sysemu.h" +#include "ui/input.h" + +#include <sys/ioctl.h> +#include "standard-headers/linux/input.h" + +typedef struct InputLinux InputLinux ; + +struct InputLinux { +const char *evdev; +int fd; +bool grab_request; +bool grab_active; +bool keydown[KEY_CNT ]; +int keycount; +int wheel; +}; + +static void input_linux_toggle_grab (InputLinux *il) +{ +intptr_t request = !il->grab_active; +int rc; + + rc =ioctl (il->fd,EVIOCGRAB , request); +if (rc <0 ) { +return ; + } + il->grab_active = !il->grab_active; +} + +static void input_linux_event_keyboard (void *opaque) +{ +InputLinux *il = opaque; +struct input_event event; +int rc; + +for (;;) { + rc =read (il->fd, &event,sizeof (event)); +if (rc !=sizeof (event)) { +break ; + } + +switch (event.type) { +case EV_KEY : +if (event.value >1 ) { +/* +* ignore autorepeat + unknown key events +* 0 == up, 1 == down, 2 == autorepeat, other == undefined +*/ +continue ; + } +/* keep track of key state */ +if (!il->keydown[event.code] && event.value) { + il->keydown[event.code] = true; + il->keycount++; + } +if (il->keydown[event.code] && !event.value) { + il->keydown[event.code] = false; + il->keycount--; + } + +/* send event to guest when grab is active */ +if (il->grab_active) { +int qcode =qemu_input_linux_to_qcode (event.code); +qemu_input_event_send_key_qcode (NULL , qcode, event.value); + } + +/* hotkey -> record switch request ... */ +if (il->keydown[KEY_LEFTCTRL ] && + il->keydown[KEY_RIGHTCTRL ]) { + il->grab_request = true; + } + +/* +* ... and do the switch when all keys are lifted, so we +* confuse neither guest nor host with keys which seem to +* be stuck due to missing key-up events. +*/ +if (il->grab_request && !il->keycount) { + il->grab_request = false; +input_linux_toggle_grab (il); + } +break ; + } + } +} + +static void input_linux_event_mouse_button (int button) +{ +qemu_input_queue_btn (NULL , button, true); +qemu_input_event_sync (); +qemu_input_queue_btn (NULL , button, false); +qemu_input_event_sync (); +} + +static void input_linux_event_mouse (void *opaque) +{ +InputLinux *il = opaque; +struct input_event event; +int rc; + +for (;;) { + rc =read (il->fd, &event,sizeof (event)); +if (rc !=sizeof (event)) { +break ; + } + +switch (event.type) { +case EV_KEY : +switch (event.code) { +case BTN_LEFT : + qemu_input_queue_btn(NULL, INPUT_BUTTON_LEFT,event.value);
ui/input-linux.c new file +3
-0+break ; +case BTN_RIGHT : + qemu_input_queue_btn(NULL, INPUT_BUTTON_RIGHT,event.value);
ui/input-linux.c new file +3
-0+break ; +case BTN_MIDDLE : + qemu_input_queue_btn(NULL, INPUT_BUTTON_MIDDLE,event.value);
ui/input-linux.c new file +3
-0+break ; +case BTN_GEAR_UP : + qemu_input_queue_btn(NULL, INPUT_BUTTON_WHEEL_UP,event.value);
ui/input-linux.c new file +103
-0+break ; +case BTN_GEAR_DOWN : +qemu_input_queue_btn (NULL ,INPUT_BUTTON_WHEEL_DOWN , + event.value); +break ; + }; +break ; +case EV_REL : +switch (event.code) { +case REL_X : +qemu_input_queue_rel (NULL ,INPUT_AXIS_X , event.value); +break ; +case REL_Y : +qemu_input_queue_rel (NULL ,INPUT_AXIS_Y , event.value); +break ; +case REL_WHEEL : + il->wheel = event.value; +break ; + } +break ; +case EV_SYN : +qemu_input_event_sync (); +if (il->wheel !=0 ) { +input_linux_event_mouse_button ((il->wheel >0 ) + ?INPUT_BUTTON_WHEEL_UP + :INPUT_BUTTON_WHEEL_DOWN ); + il->wheel =0 ; + } +break ; + } + } +} + +int input_linux_init (void *opaque,QemuOpts *opts,Error **errp) +{ +InputLinux *il =g_new0 (InputLinux,1 ); +uint32_t evtmap; +int rc, ver; + + il->evdev =qemu_opt_get (opts,"evdev" ); +if (!il->evdev) { +error_setg (errp,"no input device specified" ); + goto err_free; + } + + il->fd =open (il->evdev,O_RDWR ); +if (il->fd <0 ) { +error_setg_file_open (errp, errno, il->evdev); + goto err_free; + } +qemu_set_nonblock (il->fd); + + rc =ioctl (il->fd,EVIOCGVERSION , &ver); +if (rc <0 ) { +error_setg (errp,"%s: is not an evdev device" , il->evdev); + goto err_close; + } + + rc =ioctl (il->fd,EVIOCGBIT (0 ,sizeof (evtmap)), &evtmap); + +if (evtmap & (1 <<EV_REL )) { +/* has relative axis -> assume mouse */ +qemu_set_fd_handler (il->fd, input_linux_event_mouse,NULL , il); + }else if (evtmap & (1 <<EV_ABS )) { +/* has absolute axis -> not supported */ +error_setg (errp,"tablet/touchscreen not supported" ); + goto err_close; + }else if (evtmap & (1 <<EV_KEY )) { +/* has keys/buttons (and no axis) -> assume keyboard */ +qemu_set_fd_handler (il->fd, input_linux_event_keyboard,NULL , il); + }else { +/* Huh? What is this? */ +error_setg (errp,"unknown kind of input device" ); + goto err_close; + } +input_linux_toggle_grab (il); +return 0 ; + +err_close: +close (il->fd); +err_free: +g_free (il); +return -1 ; +} + +static QemuOptsList qemu_input_linux_opts = { + .name ="input-linux" , + .head =QTAILQ_HEAD_INITIALIZER (qemu_input_linux_opts.head), + .implied_opt_name ="evdev" , + .desc = { + { + .name ="evdev" , + .type =QEMU_OPT_STRING , + }, + {/* end of list */ } + }, +}; + +static void input_linux_register_config (void ) +{ +qemu_add_opts (&qemu_input_linux_opts); +} +machine_init (input_linux_register_config);vl.c +7
-0@@ -78,6 +78,7 @@ int main(int argc, char **argv)#include "net/slirp.h" #include "monitor/monitor.h" #include "ui/console.h" +#include "ui/input.h" #include "sysemu/sysemu.h" #include "sysemu/numa.h" #include "exec/gdbstub.h" @@ -3742,6 +3743,12 @@ int main(int argc, char **argv, char **envp)#endif break ; } +case QEMU_OPTION_input_linux: +if (!qemu_opts_parse_noisily (qemu_find_opts ("input-linux" ), + optarg, true)) { +exit (1 ); + } +break ;case QEMU_OPTION_no_acpi: acpi_enabled =0 ;break;vl.c +4
-1@@ -4622,6 +4629,10 @@ int main(int argc, char **argv, char **envp)qemu_spice_display_init (); }#endif +#ifdef CONFIG_LINUX +qemu_opts_foreach (qemu_find_opts ("input-linux" ), + input_linux_init,NULL , &error_fatal); +#endif if (foreach_device_config (DEV_GDB , gdbserver_start) <0 ) {exit (1 ); --1.8.3.1
_______________________________________________
vfio-users mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/vfio-users
PATCH v2 3/3 input-linux: add option to toggle grab on all devices
In reply to Gerd HoffmannMaintain a list of all input devices. Add an option to make grab work across all devices (so toggling grab on the keybard can switch over the mouse too).
--- ui/input-linux.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
ui/input-linux.c +29 -0
@@ -20,14 +20,19 @@ struct InputLinux {int fd;bool grab_request;bool grab_active; +bool grab_all;bool keydown[KEY_CNT ];int keycount;int wheel; +QTAILQ_ENTRY (InputLinux) next; }; +static QTAILQ_HEAD(, InputLinux) inputs = QTAILQ_HEAD_INITIALIZER(inputs); +static void input_linux_toggle_grab (InputLinux *il) {intptr_t request = !il->grab_active; +InputLinux *item;int rc; rc =ioctl (il->fd,EVIOCGRAB , request);
@@ -35,6 +40,19 @@ static void input_linux_toggle_grab(InputLinux *il)return ; } il->grab_active = !il->grab_active; + +if (!il->grab_all) { +return ; + } + QTAILQ_FOREACH(item, &inputs, next) { +if (item == il || item->grab_all) { +/* avoid endless loops */ +continue ; + } +if (item->grab_active != il->grab_active) { +input_linux_toggle_grab (item); + } + } }static void input_linux_event_keyboard (void *opaque)
@@ -114,6 +132,11 @@ static void input_linux_event_mouse(void *opaque)break ; } +/* only send event to guest when grab is active */ +if (!il->grab_active) { +continue ; + } +switch (event.type) {case EV_KEY :switch (event.code) {
@@ -168,6 +191,8 @@ int input_linux_init(void *opaque, QemuOpts *opts, Error **errp)int rc, ver; il->evdev =qemu_opt_get (opts,"evdev" ); + il->grab_all =qemu_opt_get_bool (opts,"grab-all" , false); +if (!il->evdev) {error_setg (errp,"no input device specified" ); goto err_free;
@@ -204,6 +229,7 @@ int input_linux_init(void *opaque, QemuOpts *opts, Error **errp) goto err_close; }input_linux_toggle_grab (il); +QTAILQ_INSERT_TAIL (&inputs, il, next);return 0 ; err_close:
@@ -221,6 +247,9 @@ static QemuOptsList qemu_input_linux_opts = { { .name = "evdev", .type = QEMU_OPT_STRING, + },{ + .name = "grab-all", + .type = QEMU_OPT_BOOL, }, {/* end of list */ } },
Signature · 1 line
1.8.3.1
Hi,
I tried these patches with qemu 2.5.0 on Gentoo and libvirt. I get the following error:
Error starting domain: internal error: early end of file from monitor:
possible problem:
2015-12-22T21:51:20.659520Z qemu-system-x86_64: -input-linux
/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd,grab-all=on:
Could not open '/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd'
I also tried setting /dev/input/event9 to permissions of 666 to see if it was a permission error, but the same thing happened. Any help would be appreciated.
The way I pass it is with this:
<qemu:commandline>
<qemu:arg value='-input-linux'/>
<qemu:arg
value='/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd,grab-all=on'/>
<qemu:arg value='-input-linux'/>
<qemu:arg
value='/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.1-event-mouse'/>
<qemu:arg value='-input-linux'/>
<qemu:argvalue='/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.2-event-joystick'/>
</qemu:commandline>
Is there a way around this error?
Thanks,
Jon
Quoted 197 lines · Gerd Hoffmann
Signed-off-by Gerd Hoffmann <[email protected]>--- include/ui/input.h | 3 ++ ui/input-keymap.c | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+)include/ui/input.h +3
-0@@ -48,6 +48,9 @@ int qemu_input_key_value_to_qcode(const KeyValue *value);int qemu_input_key_value_to_scancode (const KeyValue *value,bool down,int *codes); +int qemu_input_qcode_to_linux (unsigned int qcode); +int qemu_input_linux_to_qcode (unsigned int lnx); +InputEvent *qemu_input_event_new_btn (InputButton btn,bool down);void qemu_input_queue_btn (QemuConsole *src,InputButton btn,bool down); void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,ui/input-keymap.c +145
-1@@ -2,6 +2,126 @@#include "ui/keymaps.h" #include "ui/input.h" +#include "standard-headers/linux/input.h" + +/* FIXME: duplicate, see hw/input/virtio-input-hid.c */ +static const unsigned int qcode_to_linux[Q_KEY_CODE_MAX ] = { + [Q_KEY_CODE_ESC ] =KEY_ESC , + [Q_KEY_CODE_1 ] =KEY_1 , + [Q_KEY_CODE_2 ] =KEY_2 , + [Q_KEY_CODE_3 ] =KEY_3 , + [Q_KEY_CODE_4 ] =KEY_4 , + [Q_KEY_CODE_5 ] =KEY_5 , + [Q_KEY_CODE_6 ] =KEY_6 , + [Q_KEY_CODE_7 ] =KEY_7 , + [Q_KEY_CODE_8 ] =KEY_8 , + [Q_KEY_CODE_9 ] =KEY_9 , + [Q_KEY_CODE_0 ] =KEY_0 , + [Q_KEY_CODE_MINUS ] =KEY_MINUS , + [Q_KEY_CODE_EQUAL ] =KEY_EQUAL , + [Q_KEY_CODE_BACKSPACE ] =KEY_BACKSPACE , + + [Q_KEY_CODE_TAB ] =KEY_TAB , + [Q_KEY_CODE_Q ] =KEY_Q , + [Q_KEY_CODE_W ] =KEY_W , + [Q_KEY_CODE_E ] =KEY_E , + [Q_KEY_CODE_R ] =KEY_R , + [Q_KEY_CODE_T ] =KEY_T , + [Q_KEY_CODE_Y ] =KEY_Y , + [Q_KEY_CODE_U ] =KEY_U , + [Q_KEY_CODE_I ] =KEY_I , + [Q_KEY_CODE_O ] =KEY_O , + [Q_KEY_CODE_P ] =KEY_P , + [Q_KEY_CODE_BRACKET_LEFT ] =KEY_LEFTBRACE , + [Q_KEY_CODE_BRACKET_RIGHT ] =KEY_RIGHTBRACE , + [Q_KEY_CODE_RET ] =KEY_ENTER , + + [Q_KEY_CODE_CTRL ] =KEY_LEFTCTRL , + [Q_KEY_CODE_A ] =KEY_A , + [Q_KEY_CODE_S ] =KEY_S , + [Q_KEY_CODE_D ] =KEY_D , + [Q_KEY_CODE_F ] =KEY_F , + [Q_KEY_CODE_G ] =KEY_G , + [Q_KEY_CODE_H ] =KEY_H , + [Q_KEY_CODE_J ] =KEY_J , + [Q_KEY_CODE_K ] =KEY_K , + [Q_KEY_CODE_L ] =KEY_L , + [Q_KEY_CODE_SEMICOLON ] =KEY_SEMICOLON , + [Q_KEY_CODE_APOSTROPHE ] =KEY_APOSTROPHE , + [Q_KEY_CODE_GRAVE_ACCENT ] =KEY_GRAVE , + + [Q_KEY_CODE_SHIFT ] =KEY_LEFTSHIFT , + [Q_KEY_CODE_BACKSLASH ] =KEY_BACKSLASH , + [Q_KEY_CODE_LESS ] =KEY_102ND , + [Q_KEY_CODE_Z ] =KEY_Z , + [Q_KEY_CODE_X ] =KEY_X , + [Q_KEY_CODE_C ] =KEY_C , + [Q_KEY_CODE_V ] =KEY_V , + [Q_KEY_CODE_B ] =KEY_B , + [Q_KEY_CODE_N ] =KEY_N , + [Q_KEY_CODE_M ] =KEY_M , + [Q_KEY_CODE_COMMA ] =KEY_COMMA , + [Q_KEY_CODE_DOT ] =KEY_DOT , + [Q_KEY_CODE_SLASH ] =KEY_SLASH , + [Q_KEY_CODE_SHIFT_R ] =KEY_RIGHTSHIFT , + + [Q_KEY_CODE_ALT ] =KEY_LEFTALT , + [Q_KEY_CODE_SPC ] =KEY_SPACE , + [Q_KEY_CODE_CAPS_LOCK ] =KEY_CAPSLOCK , + + [Q_KEY_CODE_F1 ] =KEY_F1 , + [Q_KEY_CODE_F2 ] =KEY_F2 , + [Q_KEY_CODE_F3 ] =KEY_F3 , + [Q_KEY_CODE_F4 ] =KEY_F4 , + [Q_KEY_CODE_F5 ] =KEY_F5 , + [Q_KEY_CODE_F6 ] =KEY_F6 , + [Q_KEY_CODE_F7 ] =KEY_F7 , + [Q_KEY_CODE_F8 ] =KEY_F8 , + [Q_KEY_CODE_F9 ] =KEY_F9 , + [Q_KEY_CODE_F10 ] =KEY_F10 , + [Q_KEY_CODE_NUM_LOCK ] =KEY_NUMLOCK , + [Q_KEY_CODE_SCROLL_LOCK ] =KEY_SCROLLLOCK , + + [Q_KEY_CODE_KP_0 ] =KEY_KP0 , + [Q_KEY_CODE_KP_1 ] =KEY_KP1 , + [Q_KEY_CODE_KP_2 ] =KEY_KP2 , + [Q_KEY_CODE_KP_3 ] =KEY_KP3 , + [Q_KEY_CODE_KP_4 ] =KEY_KP4 , + [Q_KEY_CODE_KP_5 ] =KEY_KP5 , + [Q_KEY_CODE_KP_6 ] =KEY_KP6 , + [Q_KEY_CODE_KP_7 ] =KEY_KP7 , + [Q_KEY_CODE_KP_8 ] =KEY_KP8 , + [Q_KEY_CODE_KP_9 ] =KEY_KP9 , + [Q_KEY_CODE_KP_SUBTRACT ] =KEY_KPMINUS , + [Q_KEY_CODE_KP_ADD ] =KEY_KPPLUS , + [Q_KEY_CODE_KP_DECIMAL ] =KEY_KPDOT , + [Q_KEY_CODE_KP_ENTER ] =KEY_KPENTER , + [Q_KEY_CODE_KP_DIVIDE ] =KEY_KPSLASH , + [Q_KEY_CODE_KP_MULTIPLY ] =KEY_KPASTERISK , + + [Q_KEY_CODE_F11 ] =KEY_F11 , + [Q_KEY_CODE_F12 ] =KEY_F12 , + + [Q_KEY_CODE_CTRL_R ] =KEY_RIGHTCTRL , + [Q_KEY_CODE_SYSRQ ] =KEY_SYSRQ , + [Q_KEY_CODE_ALT_R ] =KEY_RIGHTALT , + + [Q_KEY_CODE_HOME ] =KEY_HOME , + [Q_KEY_CODE_UP ] =KEY_UP , + [Q_KEY_CODE_PGUP ] =KEY_PAGEUP , + [Q_KEY_CODE_LEFT ] =KEY_LEFT , + [Q_KEY_CODE_RIGHT ] =KEY_RIGHT , + [Q_KEY_CODE_END ] =KEY_END , + [Q_KEY_CODE_DOWN ] =KEY_DOWN , + [Q_KEY_CODE_PGDN ] =KEY_PAGEDOWN , + [Q_KEY_CODE_INSERT ] =KEY_INSERT , + [Q_KEY_CODE_DELETE ] =KEY_DELETE , + + [Q_KEY_CODE_META_L ] =KEY_LEFTMETA , + [Q_KEY_CODE_META_R ] =KEY_RIGHTMETA , + [Q_KEY_CODE_MENU ] =KEY_MENU , +}; +static const int qcode_to_number[] = { [Q_KEY_CODE_SHIFT ] =0x2a , [Q_KEY_CODE_SHIFT_R ] =0x36 ,@@ -136,6 +256,7 @@ static const int qcode_to_number[] = { };static int number_to_qcode[0x100 ]; +static int linux_to_qcode[KEY_CNT ];int qemu_input_key_value_to_number (const KeyValue *value) {@@ -200,3 +321,27 @@ int qemu_input_key_value_to_scancode(const KeyValue *value, bool down, return count; } + +int qemu_input_qcode_to_linux (unsigned int qcode) +{ +assert (qcode <Q_KEY_CODE_MAX ); +return qcode_to_linux[qcode]; +} + +int qemu_input_linux_to_qcode (unsigned int lnx) +{ +static int first = true; + +if (first) { +int qcode, number; + first = false; +for (qcode =0 ; qcode <Q_KEY_CODE_MAX ; qcode++) { + number = qcode_to_linux[qcode]; +assert (number <KEY_CNT ); + linux_to_qcode[number] = qcode; + } + } + +assert (lnx <KEY_CNT ); +return linux_to_qcode[lnx]; +} --1.8.3.1
_______________________________________________
vfio-users mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/vfio-users
Quoted 7 lines · Jonathan Scruggs
Hi,
I tried these patches with qemu 2.5.0 on Gentoo and libvirt. I get the following error:
Error starting domain: internal error: early end of file from monitor:
possible problem:
Quoted 7 lines
2015-12-22T21:51:20.659520Z qemu-system-x86_64:-input-linux /dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd,grab-all=on: Could not open '/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd'
I also tried setting
/dev/input/event9to permissions of 666 to see if it was a permission error, but the same thing happened. Any help would be appreciated.
libvirt uses cgroups to restrict qemu. You can tweak cgroup_controllers in /etc/libvirt/qemu.conf, when you remove "devices" controller it should work (unless something else like selinux or apparmor applies additional restrictions).
HTH,
Gerd
Hi,
Thanks for the reply.
I changed the conf to:cgroup_controllers = [ "cpu", "memory", "cpuset", "cpuacct" ] Also, cgroups are not mounted at /dev/cgroup
I don't have selinux or apparmor.
However, I still get this:
Error starting domain: internal error: early end of file from monitor, possible problem: 2016-01-04T13:07:17.889701Z qemu-system-x86_64:
-input-linux /dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd,grab-all=on:
Could not open '/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd'
Thanks,
Jon
Quoted 27 lines · Gerd Hoffmann
Quoted 9 lines · Jonathan Scruggs
Hi,
I tried these patches with qemu 2.5.0 on Gentoo and libvirt. I get the following error:
Error starting domain: internal error: early end of file from monitor:
possible problem:2015-12-22T21:51:20.659520Z qemu-system-x86_64:-input-linux
/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd,grab-all=on:
Could not open '/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd'Quoted 5 lines
I also tried setting
/dev/input/event9to permissions of 666 to see if it was a permission error, but the same thing happened. Any help would be appreciated.libvirt uses cgroups to restrict qemu. You can tweak
cgroup_controllersin/etc/libvirt/qemu.conf, when you remove "devices" controller it should work (unless something else like selinux or apparmor applies additional restrictions).HTH,
Gerd
Oh. I just changed /dev/input/eventx (replace x with correct number for my devices) to permissions of 666 and it worked. I guess I had to change the conf file and change the permissions. Is there a way to make the devices work with qemu? The permission user is root and group of input for all the eventx devices. Do I need a udev script or is there a qemu user that can be added to the group of input?
Thanks
Quoted 27 lines · Gerd Hoffmann
Quoted 9 lines · Jonathan Scruggs
Hi,
I tried these patches with qemu 2.5.0 on Gentoo and libvirt. I get the following error:
Error starting domain: internal error: early end of file from monitor:
possible problem:2015-12-22T21:51:20.659520Z qemu-system-x86_64:-input-linux
/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd,grab-all=on:
Could not open '/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd'Quoted 5 lines
I also tried setting
/dev/input/event9to permissions of 666 to see if it was a permission error, but the same thing happened. Any help would be appreciated.libvirt uses cgroups to restrict qemu. You can tweak
cgroup_controllersin/etc/libvirt/qemu.conf, when you remove "devices" controller it should work (unless something else like selinux or apparmor applies additional restrictions).HTH,
Gerd
A message that is not in the archive (sent off-list or not yet received): CAAaYXTufBXAyrc0tNkOmRWZ6qmGW5qpyfAfjmOnRsHpgi4H1YA@mail.gmail.com
PATCH v2 1/3 input: add qemu_input_qcode_to_linux + qemu_input_linux_to_qcode
2016-01-04 14:19 GMT+01:00 Jonathan Scruggs <[email protected]>:
Quoted 7 lines
Oh. I just changed
/dev/input/eventx(replace x with correct number for my devices) to permissions of 666 and it worked. I guess I had to change the conf file and change the permissions. Is there a way to make the devices work with qemu? The permission user is root and group of input for all the eventx devices. Do I need a udev script or is there a qemu user that can be added to the group of input?
Quoted 30 lines
Thanks
Quoted 27 lines · Gerd Hoffmann
Quoted 8 lines · Jonathan Scruggs
Hi,
I tried these patches with qemu 2.5.0 on Gentoo and libvirt. I get the following error:
Error starting domain: internal error: early end of file from monitor:
possible problem:2015-12-22T21:51:20.659520Z qemu-system-x86_64:Quoted 8 lines
-input-linux /dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd,grab-all=on:
Could not open '/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd'I also tried setting
/dev/input/event9to permissions of 666 to see if it was a permission error, but the same thing happened. Any help would be appreciated.libvirt uses cgroups to restrict qemu. You can tweak
cgroup_controllersin/etc/libvirt/qemu.conf, when you remove "devices" controller it should work (unless something else like selinux or apparmor applies additional restrictions).HTH,
Gerd
I tried add myself to input group. don't work.
not test if add root user to input group works
but can confirm if change all /dev/input/eventx to 0666 works the keyboard/mouse on the guest
i have in the qemu.conf:
use r= root
group = kvmcgroup_controllers = [ "cpu", "memory", "blkio", "cpuset", "cpuacct" ]
and add myself to groups libvirt (created by libvirt) and kvm (created by qemu)
Quoted 6 lines · Jonathan Scruggs
Oh. I just changed
/dev/input/eventx(replace x with correct number for my devices) to permissions of 666 and it worked. I guess I had to change the conf file and change the permissions. Is there a way to make the devices work with qemu? The permission user is root and group of input for all the eventx devices. Do I need a udev script or is there a qemu user that can be added to the group of input?
I'm using chmod 666, adding the qemu user to the input group should work too.
cheers,
Gerd
I found the qemu user yesterday and added it to the input group. All is good now. The patches work great! Are they being added to the main code base soon? A small faq on the site detailing libvirt usage and adding qemu to the input group would be needed though.
I notice no bugs as of yet. The mouse fully disengages from each system unlike an earlier report I read in this mailing list. This is perfect and precisely what I requested many months ago when vfio-users mailing list first started. :)
Thanks for all your work on this,
Jon
Quoted 16 lines · Gerd Hoffmann
Quoted 6 lines · Jonathan Scruggs
Oh. I just changed
/dev/input/eventx(replace x with correct number for my devices) to permissions of 666 and it worked. I guess I had to change the conf file and change the permissions. Is there a way to make the devices work with qemu? The permission user is root and group of input for all the eventx devices. Do I need a udev script or is there a qemu user that can be added to the group of input?I'm using chmod 666, adding the qemu user to the input group should work too.
cheers,
Gerd
2016-01-05 9:06 GMT+01:00 Jonathan Scruggs <[email protected]>:
Quoted 1 line
I notice no bugs as of yet.
Hi
I found one (if can call that) bug
I use a physical USB switch for share the K/M with other PC when switch to other pc, lost the signal. this is ok. but the VM start stutter (the sounds and videos), and when is back, can't recover the signal in the VM. requiring restart the guest
This is expected?
btw. I found solution for the kb/mouse permissions on my setup. qemu is launched with root user. Then I added the root to group input. now no need set 0666 to /dev/input/eventX and can use the keyboard/mouse without apparent problems (better than passthrough (need use other keyboard for host)) and synergy (in games can't rotate the camera in all degrees).
Greetings
Quoted 8 lines · On Di, 2016-01-05 at 15:44 +0100, sL1pKn07 SpinFlo wrote:
2016-01-05 9:06 GMT+01:00 Jonathan Scruggs <[email protected]>:
Quoted 1 line
I notice no bugs as of yet.
Hi
I found one (if can call that) bugI use a physical USB switch for share the K/M with other PC when switch to other pc, lost the signal.
How does the switch work? Disconnect the usb devices (i.e. they are gone from lsusb output)?
cheers,
Gerd
A message that is not in the archive (sent off-list or not yet received): CAAaYXTvQJmgZEz8AUfe5GNULcbpN7TA8DdCNDFxD4yZKAju=kg@mail.gmail.com
PATCH v2 1/3 input: add qemu_input_qcode_to_linux + qemu_input_linux_to_qcode
Yes, is like disconect the cable of USB.
http://sl1pkn07.wtf/imagenes/kvm01.jpg
http://sl1pkn07.wtf/imagenes/kvm04.jpg
Greetings.
Quoted 17 lines · Gerd Hoffmann
Quoted 8 lines · On Di, 2016-01-05 at 15:44 +0100, sL1pKn07 SpinFlo wrote:
2016-01-05 9:06 GMT+01:00 Jonathan Scruggs <[email protected]>:
Quoted 1 line
I notice no bugs as of yet.
Hi
I found one (if can call that) bugI use a physical USB switch for share the K/M with other PC when switch to other pc, lost the signal.
How does the switch work? Disconnect the usb devices (i.e. they are gone from lsusb output)?
cheers,
Gerd
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/3 input: add qemu_input_qcode_to_linux + qemu_input_linux_to_qcode
Quoted 1 line · On Mi, 2016-01-06 at 13:42 +0100, sL1pKn07 SpinFlo wrote:
Yes, is like disconect the cable of USB.
Ok. That is not so easy. Well, the first part (switch away) is easy, it is just a matter of catching read errors, so the device going away (unplug) doesn't screw up things. But when it comes to reconnect after switching back it'll quickly becomes quite messy ...
cheers,
Gerd
Today have notice the patch stop working on my VM
input_linux_event_mouse: read: Resource temporarily unavailable input_linux_event_keyboard: read: Resource temporarily unavailable
i only rebuild qemu (from Gerd Hoffmann's input-dev-event barnch) with some changes.
this is my options:
./configure \
--python=/usr/bin/python2 \
--prefix=/usr \
--sysconfdir=/etc \
--audio-drv-list='pa alsa sdl' \
--localstatedir=/var \
--libexecdir=/usr/lib/qemu \
--enable-sdl \
--with-sdlabi=2.0 \
--enable-linux-aio \
--enable-seccomp \
--enable-tpm \
--enable-modules \
--disable-gtk \
--disable-spice \
--disable-rbd \
--disable-libiscsi \
--disable-libnfs \
--disable-smartcard \
--disable-glusterfs \
--disable-docs \
--disable-vnc{,-sasl,-jpeg,-png}I only disable spice,vnc,smartcard,glusterfs,iscsi,rbd,docs,libnfs and add sdlabi=2.0
is a regression or one of the disable components is necessary to run the patch?
greetings
2016-01-07 5:57 GMT+01:00 sL1pKn07 SpinFlo <[email protected]>:
Quoted 10 lines · On Mi, 2016-01-06 at 13:42 +0100, sL1pKn07 SpinFlo wrote:
Quoted 1 line
Yes, is like disconect the cable of USB.
Ok. That is not so easy. Well, the first part (switch away) is easy, it is just a matter of catching read errors, so the device going away (unplug) doesn't screw up things. But when it comes to reconnect after switching back it'll quickly becomes quite messy ...
cheers,
Gerd
ok, now works tnx Gerd!
but i found 2 problems, one with keyboard and other with the mouse
Keyboard:
the repetition (hold the key) don't work.
Mouse:
only detect 3 buttons (my Logitech G5 Laser Have 7)
this is spected?
greetings
Quoted 8 lines · On Fr, 2016-01-15 at 00:19 +0100, sL1pKn07 SpinFlo wrote:
ok, now works tnx Gerd!
but i found 2 problems, one with keyboard and other with the mouse
Keyboard:
the repetition (hold the key) don't work.
Support used to be there, but the constant flow of key repeat events in case you hold down a key longer (like you do with shift or ctrl in some games) made things unstable so I turned that off.
Quoted 3 lines
Mouse:
only detect 3 buttons (my Logitech G5 Laser Have 7)
The mouse emulated by qemu has only three buttons.
cheers,
Gerd
A message that is not in the archive (sent off-list or not yet received): CAAaYXTuX0qzgwqF0TWoVQ1zBKcNOWDEVUjat8Pe5XzP4PhHifw@mail.gmail.com
PATCH v2 1/3 input: add qemu_input_qcode_to_linux + qemu_input_linux_to_qcode
---------- Forwarded message ----------
From: sL1pKn07 SpinFlo <[email protected]>
Date: 2016-01-15 13:48 GMT+01:00
Subject: Re: [vfio-users] [PATCH v2 1/3] input: add qemu_input_qcode_to_linux + qemu_input_linux_to_qcode
To: Gerd Hoffmann <[email protected]>
2016-01-15 9:50 GMT+01:00 Gerd Hoffmann <[email protected]>:
Quoted 5 lines
The mouse emulated by qemu has only three buttons.
cheers,
Gerd
mmmnnn
---------------------------------------------------------------------------------------------------------
hw/input/hid.c +0 -0
@@ -109,9 +109,13 @@ static void hid_pointer_event(DeviceState *dev,
QemuConsole *src,
InputEvent *evt)
{
static const int bmap[INPUT_BUTTON__MAX] = {
- [INPUT_BUTTON_LEFT] = 0x01,
- [INPUT_BUTTON_RIGHT] = 0x02,
- [INPUT_BUTTON_MIDDLE] = 0x04,
+ [INPUT_BUTTON_LEFT] = 0x01,
+ [INPUT_BUTTON_RIGHT] = 0x02,
+ [INPUT_BUTTON_MIDDLE] = 0x04,
+ [INPUT_BUTTON_WHELLLEFT] = 0x??, /* FIXME! */
+ [INPUT_BUTTON_WHELLRIGHT] = 0x??, /* FIXME! */
+ [INPUT_BUTTON_FN1] = 0x??, /* FIXME! */
+ [INPUT_BUTTON_FN2] = 0x??, /* FIXME! */
};
HIDState *hs = (HIDState *)dev;
HIDPointerEvent *e;hw/input/ps2.c +0 -0
@@ -383,9 +383,13 @@ static void ps2_mouse_event(DeviceState *dev,
QemuConsole *src,
InputEvent *evt)
{
static const int bmap[INPUT_BUTTON__MAX] = {
- [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON,
- [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON,
- [INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON,
+ [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON,
+ [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON,
+ [INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON,
+ [INPUT_BUTTON_WHELLLEFT] = MOUSE_EVENT_WLBUTTON,
+ [INPUT_BUTTON_WHELLRIGHT] = MOUSE_EVENT_WRRBUTTON,
+ [INPUT_BUTTON_FN1] = MOUSE_EVENT_FN1BUTTON,
+ [INPUT_BUTTON_FN2] = MOUSE_EVENT_FN2BUTTON,
};
PS2MouseState *s = (PS2MouseState *)dev;hw/input/virtio-input-hid.c +0 -0
@@ -144,6 +144,10 @@ static const unsigned int
keymap_button[INPUT_BUTTON__MAX] = {
[INPUT_BUTTON_MIDDLE] = BTN_MIDDLE,
[INPUT_BUTTON_WHEELUP] = BTN_GEAR_UP,
[INPUT_BUTTON_WHEELDOWN] = BTN_GEAR_DOWN,
+ [INPUT_BUTTON_WHELLLEFT] = BTN_GEAR_LEFT,
+ [INPUT_BUTTON_WHELLRIGHT] = BTN_GEAR_RIGHT,
+ [INPUT_BUTTON_FN1] = BTN_FUNCTION_1,
+ [INPUT_BUTTON_FN2] = BTN_FUNCTION_2,};
static const unsigned int axismap_rel[INPUT_AXIS__MAX] = {
(quoted diff) +0 -0
b/include/standard-headers/linux/input-event-codes.h index 354f0de..0df11c7 100644
include/standard-headers/linux/input-event-codes.h +5 -0
@@ -416,6 +416,11 @@#define BTN_WHEEL 0x150#define BTN_GEAR_DOWN 0x150#define BTN_GEAR_UP 0x151 +#define BTN_GEAR_LEFT 0x???/* FIXME! */ +#define BTN_GEAR_RIGHT 0x???/* FIXME! */ +#define BTN_FUNCTION_1 0x???/* FIXME! */ +#define BTN_FUNCTION_2 0x???/* FIXME! */ +#define KEY_OK 0x160#define KEY_SELECT 0x161
monitor.c +0 -0
@@ -1390,6 +1390,10 @@ static void hmp_mouse_button(Monitor *mon,
const QDict *qdict)
[INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON,
[INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON,
[INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON,
+ [INPUT_BUTTON_WHELLLEFT] = MOUSE_EVENT_WLBUTTON,
+ [INPUT_BUTTON_WHELLRIGHT] = MOUSE_EVENT_WRRBUTTON,
+ [INPUT_BUTTON_FN1] = MOUSE_EVENT_FN1BUTTON,
+ [INPUT_BUTTON_FN2] = MOUSE_EVENT_FN2BUTTON,
};
int button_state = qdict_get_int(qdict, "button_state");ui/input-linux.c +11 -0
@@ -212,6 +212,17 @@ static void input_linux_event_mouse(void *opaque)case BTN_GEAR_DOWN :qemu_input_queue_btn (NULL ,INPUT_BUTTON_WHEELDOWN , event.value); +case BTN_GEAR_LEFT : +qemu_input_queue_btn (NULL ,INPUT_BUTTON_WHELLLEFT , + event.value); +case BTN_GEAR_RIGHT : +qemu_input_queue_btn (NULL ,INPUT_BUTTON_WHELLRIGHT , + event.value); +case BTN_FUNCTION_1 : +qemu_input_queue_btn (NULL ,INPUT_BUTTON_FN1 , event.value); +break ; +case BTN_FUNCTION_1 : +qemu_input_queue_btn (NULL ,INPUT_BUTTON_FN2 , event.value);break ; };break ;
---------------------------------------------------------------------------------------------------------
for add more buttons is something like this?
how I can get the values of "FIXME" parameters?
yes, is a ugly patch (i am not coder) and make only for me... but i not want back to synergy/usb passthrough :(
greetings
PS: Mailman, oh, please ¬¬
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/3 input: add qemu_input_qcode_to_linux + qemu_input_linux_to_qcode
---------- Forwarded message ----------
From: Gerd Hoffmann <[email protected]>
Date: 2016-01-15 14:24 GMT+01:00
Subject: Re: [vfio-users] [PATCH v2 1/3] input: add qemu_input_qcode_to_linux + qemu_input_linux_to_qcode
To: sL1pKn07 SpinFlo <[email protected]>
include/standard-headers/linux/input-event-codes.h line 422
Quoted 10 lines
include/standard-headers/linux/input-event-codes.h +4
-0@@ -416,6 +416,11 @@#define BTN_WHEEL 0x150#define BTN_GEAR_DOWN 0x150#define BTN_GEAR_UP 0x151 +#define BTN_GEAR_LEFT 0x???/* FIXME! */ +#define BTN_GEAR_RIGHT 0x???/* FIXME! */ +#define BTN_FUNCTION_1 0x???/* FIXME! */ +#define BTN_FUNCTION_2 0x???/* FIXME! */
The ones sent by your mouse most likely already in the list.
Add "log=on" to the mouse, then qemu will log all mouse events it gets from the kernel to stderr, including the ones it doesn't handle. That should show which wheel and button events the mouse sends. Lets continue from there.
More buttons can be defined by adding them to InputButton in qapi-schema.json
Most tricky part is probably getting the mouse events to the guest os. quick look as the ps/2 emulation looks like there are no unused bits for more buttons. Possibly we have to extend the usb mouse emulation for that. Need to google a bit on that (any hints are welcome ;) ...
cheers,
Gerd
2016-01-15 19:06 GMT+01:00 sL1pKn07 SpinFlo <[email protected]>:
Quoted 29 lines
---------- Forwarded message ----------
From: Gerd Hoffmann <[email protected]>
Date: 2016-01-15 14:24 GMT+01:00
Subject: Re: [vfio-users] [PATCH v2 1/3] input: addqemu_input_qcode_to_linux+qemu_input_linux_to_qcode
To: sL1pKn07 SpinFlo <[email protected]>include/standard-headers/linux/input-event-codes.h line 422
Quoted 10 lines
include/standard-headers/linux/input-event-codes.h +4
-0@@ -416,6 +416,11 @@#define BTN_WHEEL 0x150#define BTN_GEAR_DOWN 0x150#define BTN_GEAR_UP 0x151 +#define BTN_GEAR_LEFT 0x???/* FIXME! */ +#define BTN_GEAR_RIGHT 0x???/* FIXME! */ +#define BTN_FUNCTION_1 0x???/* FIXME! */ +#define BTN_FUNCTION_2 0x???/* FIXME! */ The ones sent by your mouse most likely already in the list.
Add "log=on" to the mouse, then qemu will log all mouse events it gets from the kernel to stderr, including the ones it doesn't handle. That should show which wheel and button events the mouse sends. Lets continue from there.
More buttons can be defined by adding them to InputButton in qapi-schema.json
Quoted 7 lines
Most tricky part is probably getting the mouse events to the guest os. quick look as the ps/2 emulation looks like there are no unused bits for more buttons. Possibly we have to extend the usb mouse emulation for that. Need to google a bit on that (any hints are welcome ;) ...
cheers,
Gerd
With log=on
evdev: relative HWHEEL -1 <- press wheel Left
evdev: sync
evdev: relative HWHEEL 1 <- press wheel right
evdev: sync
evdev: type=MSC code=0x4 value=0x90005
evdev: key/btn BTN_EXTRA down
evdev: sync
evdev: type=MSC code=0x4 value=0x90005
evdev: key/btn BTN_EXTRA up
evdev: sync
evdev: type=MSC code=0x4 value=0x90004
evdev: key/btn BTN_SIDE down
evdev: sync
evdev: type=MSC code=0x4 value=0x90004
evdev: key/btn BTN_SIDE up
then
------------------------------------------------------------------------------------
hw/input/hid.c +0 -0
@@ -112,6 +112,8 @@ static void hid_pointer_event(DeviceState *dev,
QemuConsole *src,
[INPUT_BUTTON_LEFT] = 0x01,
[INPUT_BUTTON_RIGHT] = 0x02,
[INPUT_BUTTON_MIDDLE] = 0x04,
+ [INPUT_BUTTON_EXTRA] = 0x114,
+ [INPUT_BUTTON_SIDE] = 0x113,
};
HIDState *hs = (HIDState *)dev;
HIDPointerEvent *e;hw/input/ps2.c +0 -0
@@ -386,6 +386,8 @@ static void ps2_mouse_event(DeviceState *dev,
QemuConsole *src,
[INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON,
[INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON, [INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON,
+ [INPUT_BUTTON_EXTRA] = MOUSE_EVENT_EBUTTON,
+ [INPUT_BUTTON_SIDE] = MOUSE_EVENT_SBUTTON,
};
PS2MouseState *s = (PS2MouseState *)dev;hw/input/virtio-input-hid.c +0 -0
@@ -144,6 +144,8 @@ static const unsigned int
keymap_button[INPUT_BUTTON__MAX] = {
[INPUT_BUTTON_MIDDLE] = BTN_MIDDLE,
[INPUT_BUTTON_WHEELUP] = BTN_GEAR_UP,
[INPUT_BUTTON_WHEELDOWN] = BTN_GEAR_DOWN,
+ [INPUT_BUTTON_EXTRA] = BTN_EXTRA,
+ [INPUT_BUTTON_SIDE] = BTN_SIDE,};
static const unsigned int axismap_rel[INPUT_AXIS__MAX] = {
monitor.c +0 -0
@@ -1390,6 +1390,8 @@ static void hmp_mouse_button(Monitor *mon, const
QDict *qdict)
[INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON,
[INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON,
[INPUT_BUTTON_RIGHT] = MOUSE_EVENT_RBUTTON,
+ [INPUT_BUTTON_SIDE] = MOUSE_EVENT_SBUTTON,
+ [INPUT_BUTTON_EXTRA] = MOUSE_EVENT_EBUTTON,
};
int button_state = qdict_get_int(qdict, "button_state");qapi-schema.json +1 -1
@@ -3667,7 +3667,7 @@ # x-input-send-event is promoted out of experimental status. ## { 'enum' : 'InputButton', - 'data' : [ 'Left', 'Middle', 'Right', 'WheelUp', 'WheelDown' ] } + 'data' : [ 'Left', 'Middle', 'Right', 'WheelUp', 'WheelDown',
'WheelLeft', 'WheelRight', 'Side', 'Extra' ] }
##
# @InputAxis
ui/input-linux.c +5 -0
@@ -212,6 +212,11 @@ static void input_linux_event_mouse(void *opaque)case BTN_GEAR_DOWN :qemu_input_queue_btn (NULL ,INPUT_BUTTON_WHEELDOWN , event.value); +case BTN_EXTRA : +qemu_input_queue_btn (NULL ,INPUT_BUTTON_EXTRA , event.value); +break ; +case BTN_SIDE : +qemu_input_queue_btn (NULL ,INPUT_BUTTON_SIDE , event.value);break ; };break ;
-------------------------------------------------------
The part of whell left/right movement i don't know how paste on the code :/
and about the extra buttons on windows....
https://msdn.microsoft.com/en-us/library/windows/hardware/jj128406(v=vs.85).aspx
bad business(?)
greetings
Hi Gerd,
Would there be a way to add repeating keys back in that doesn't cause issues? Maybe slow down the repeat cycle? Or is this strictly a issue with how the actual event drivers or the buffers work and would need changing to that on the host side? In my mind it seams fairly straightforward in just forwarding these events to the VM.
Would it be different if the keyboard was using the PS/2 versus the USB interface on the guest? I have a USB controller added for the guest but the keyboard and mouse are on PS/2 interfaces.
A second thought. What if you made the keyboard and mouse USB only, then on the guest, make sure the USB controller is using Message Signal-Based interrupts. On Windows, the controller was set to the old style Line-Based. The slow downs could be caused by a lake in speed with he interrupts and USB polling speed.
Would you be able to tell me how to make the keyboard/mouse USB only and enable repeat keys, so I can investigate this option? If it works like this then a good set of instructions will need to be done to enable all this and solve an issue. :-) Also, I would need to know the cases where the slow downs happen to test.
What do you think?
-Jon
Quoted 29 lines · Gerd Hoffmann
Quoted 8 lines · On Fr, 2016-01-15 at 00:19 +0100, sL1pKn07 SpinFlo wrote:
ok, now works tnx Gerd!
but i found 2 problems, one with keyboard and other with the mouse
Keyboard:
the repetition (hold the key) don't work.
Support used to be there, but the constant flow of key repeat events in case you hold down a key longer (like you do with shift or ctrl in some games) made things unstable so I turned that off.
Quoted 3 lines
Mouse:
only detect 3 buttons (my Logitech G5 Laser Have 7)
The mouse emulated by qemu has only three buttons.
cheers,
Gerd_______________________________________________
vfio-users mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/vfio-users
Quoted 6 lines · Jonathan Scruggs
Hi Gerd,
Would there be a way to add repeating keys back in that doesn't cause issues? Maybe slow down the repeat cycle? Or is this strictly a issue with how the actual event drivers or the buffers work and would need changing to that on the host side?
I don't know ...
Quoted 2 lines
In my mind it seams fairly straightforward in just forwarding these events to the VM.
I assumed that as well, it was there initially and only removed after it turned out to cause problems.
I've added a patch to the git branch bringing it back, but guarded with a new config option (repeat={on,off}) and turned off by default.
Quoted 3 lines
Would it be different if the keyboard was using the PS/2 versus the USB interface on the guest? I have a USB controller added for the guest but the keyboard and mouse are on PS/2 interfaces.
Worth testing. Just add "-device usb-kbd" to the qemu command line and see what happens ...
Quoted 5 lines
A second thought. What if you made the keyboard and mouse USB only, then on the guest, make sure the USB controller is using Message Signal-Based interrupts. On Windows, the controller was set to the old style Line-Based. The slow downs could be caused by a lake in speed with he interrupts and USB polling speed.
In case windows is new enough to have xhci support (win8+) you can try using a xhci hostadapter, which supports MSI (uhci and ehci don't), then hook up the usb keyboard to it.
"-device nec-usb-xhci,id=xhci -device usb-kbd,bus=xhci.0"
cheers,
Gerd
Hi Gerd,
I am using qemu 2.5.0 source code and applied all the patches on your git server. This one:
https://www.kraxel.org/cgit/qemu/commit/?h=work/input-dev-event&id=b52110d4f22e99953ac5195a90988a253e3e2f90
causes the build to fail with this:
error: array index in non-array initializer
It happens on all the key binding assignments. Are there changes in the code elsewhere that this patch is for? It compiles just fine without it on the 2.5.0 sources with the latest CVE bug patches.
Jon
Quoted 42 lines · Gerd Hoffmann
Quoted 6 lines · Jonathan Scruggs
Hi Gerd,
Would there be a way to add repeating keys back in that doesn't cause issues? Maybe slow down the repeat cycle? Or is this strictly a issue with how the actual event drivers or the buffers work and would need changing to that on the host side?
I don't know ...
Quoted 2 lines
In my mind it seams fairly straightforward in just forwarding these events to the VM.
I assumed that as well, it was there initially and only removed after it turned out to cause problems.
I've added a patch to the git branch bringing it back, but guarded with a new config option (repeat={on,off}) and turned off by default.
Quoted 3 lines
Would it be different if the keyboard was using the PS/2 versus the USB interface on the guest? I have a USB controller added for the guest but the keyboard and mouse are on PS/2 interfaces.
Worth testing. Just add "-device usb-kbd" to the qemu command line and see what happens ...
Quoted 5 lines
A second thought. What if you made the keyboard and mouse USB only, then on the guest, make sure the USB controller is using Message Signal-Based interrupts. On Windows, the controller was set to the old style Line-Based. The slow downs could be caused by a lake in speed with he interrupts and USB polling speed.
In case windows is new enough to have xhci support (win8+) you can try using a xhci hostadapter, which supports MSI (uhci and ehci don't), then hook up the usb keyboard to it.
"-device nec-usb-xhci,id=xhci -device usb-kbd,bus=xhci.0"
cheers,
Gerd
Quoted 8 lines · Jonathan Scruggs
Hi Gerd,
I am using qemu 2.5.0 source code and applied all the patches on your git server. This one:
https://www.kraxel.org/cgit/qemu/commit/?h=work/input-dev-event&id=b52110d4f22e99953ac5195a90988a253e3e2f90
causes the build to fail with this:
error: array index in non-array initializer
There have been some incompatible changes between 2.5.0 and master ...
Dropping the "input-linux: adapt to qapi changes" patch might get things build on 2.5.0, didn't test that though ...
HTH,
Gerd
Hi Gerd,
A couple of options I have been wondering about.
1)
Is it possible to have an option that would enable running a program on the host on switching, IE when both CRTL keys are pressed. It would run on the host regardless if it was on the guest machine when the keys pressed. An option like 'onswitchexecute=/usr/bin/monitorswitch'
Something like that. I have a small program that switches the monitor input via I2C direct (if interested: http://pastebin.com/6Hd0pafF). The program would need to be modified a little bit to not use a variable input. but to somehow detect what it's currently at and then switch to the opposite -- shouldn't be too hard.
2)
This would be useful for number idea one.
Instead of both CTRL keys, could the hotkey be something like CTRL+SHIFT+ALT+1 for the host, and then each guest would set an option of 2 through 9. Since this is really only good for dedicated graphics cards, the most I've heard of is 7 in one machine and that was a crazy build. A normal person would have two cards, namely MS Windows Gaming Rig and GNU/Linux. However, some may want three, which is very doable on most systems. So, CTRL+SHIFT+ALT+2 or +3 to get to the other systems.
It can connect into point one, as the cheap and dirty monitor switcher code takes an input and my monitor has three inputs, so a person could write code to switch anything to anything. The option could have a variable string that when called by your Input patches, would replace the variable place holder with the machine being called, IE:
'execonswitch=/usr/bin/monitorswitch %COMPNUM'
Or something like that.
Hope you like the ideas.
Jon
Quoted 42 lines · Gerd Hoffmann
Quoted 6 lines · Jonathan Scruggs
Hi Gerd,
Would there be a way to add repeating keys back in that doesn't cause issues? Maybe slow down the repeat cycle? Or is this strictly a issue with how the actual event drivers or the buffers work and would need changing to that on the host side?
I don't know ...
Quoted 2 lines
In my mind it seams fairly straightforward in just forwarding these events to the VM.
I assumed that as well, it was there initially and only removed after it turned out to cause problems.
I've added a patch to the git branch bringing it back, but guarded with a new config option (repeat={on,off}) and turned off by default.
Quoted 3 lines
Would it be different if the keyboard was using the PS/2 versus the USB interface on the guest? I have a USB controller added for the guest but the keyboard and mouse are on PS/2 interfaces.
Worth testing. Just add "-device usb-kbd" to the qemu command line and see what happens ...
Quoted 5 lines
A second thought. What if you made the keyboard and mouse USB only, then on the guest, make sure the USB controller is using Message Signal-Based interrupts. On Windows, the controller was set to the old style Line-Based. The slow downs could be caused by a lake in speed with he interrupts and USB polling speed.
In case windows is new enough to have xhci support (win8+) you can try using a xhci hostadapter, which supports MSI (uhci and ehci don't), then hook up the usb keyboard to it.
"-device nec-usb-xhci,id=xhci -device usb-kbd,bus=xhci.0"
cheers,
Gerd
Hi,
Quoted 6 lines
1)
Is it possible to have an option that would enable running a program on the host on switching, IE when both CRTL keys are pressed. It would run on the host regardless if it was on the guest machine when the keys pressed.
An option like 'onswitchexecute=/usr/bin/monitorswitch'
Should be doable. We have other places with simliar things already (network setup for example).
Quoted 5 lines
Something like that. I have a small program that switches the monitor input via I2C direct (if interested: http://pastebin.com/6Hd0pafF).
The program would need to be modified a little bit to not use a variable input. but to somehow detect what it's currently at and then switch to the opposite -- shouldn't be too hard.
Calling the thing with "host" or "guest" as argument should be easy too.
Quoted 4 lines
This would be useful for number idea one.
Instead of both CTRL keys, could the hotkey be something like CTRL +SHIFT+ALT+1 for the host, and then each guest would set an option of 2 through 9.
Not going to work. At least not a direct guest -> guest switch, only guest1 -> host -> guest2.
cheers,
Gerd
A message that is not in the archive (sent off-list or not yet received): CAAaYXTty+R2DJ3=Uc3K3xJ+iTNEHdA4JE1_iWXdL=U3sPwqjZw@mail.gmail.com
Quoted 7 lines
libvirt uses cgroups to restrict qemu. You can tweak
cgroup_controllersin/etc/libvirt/qemu.conf, when you remove "devices" controller it should work (unless something else like selinux or apparmor applies additional restrictions).HTH,
Gerd
like this?
# What cgroup controllers to make use of with QEMU guests #
# - 'cpu' - use for schedular tunables # - 'devices' - use for device whitelisting # - 'memory' - use for memory tunables # - 'blkio' - use for block devices I/O tunables # - 'cpuset' - use for CPUs and memory nodes # - 'cpuacct' - use for CPUs statistics. # # NB, even if configured here, they won't be used unless # the administrator has mounted cgroups, e.g.: # # mkdir /dev/cgroup # mount -t cgroup -o devices,cpu,memory,blkio,cpuset none /dev/cgroup # # They can be mounted anywhere, and different controllers # can be mounted in different locations. libvirt will detect # where they are located. # cgroup_controllers = [ "cpu", "memory", "blkio", "cpuset", "cpuacct" ]
my original cgroup_controllers is commented
#cgroup_controllers = [ "cpu", "devices", "memory", "blkio", "cpuset", "cpuacct" ]
greetings
Hi,
Quoted 3 lines
like this?
cgroup_controllers= [ "cpu", "memory", "blkio", "cpuset", "cpuacct" ]
yes (+libvirtd restart so it re-reads the config).
cheers,
Gerd
A message that is not in the archive (sent off-list or not yet received): CAAaYXTvaDntkeSOKvu12UwT4FeAkspM12q94GE=keRTn-NOUsQ@mail.gmail.com
2016-01-04 11:10 GMT+01:00 Jonathan Scruggs <[email protected]>:
Quoted 25 lines
Hi,
I tried these patches with qemu 2.5.0 on Gentoo and libvirt. I get the following error:
Error starting domain: internal error: early end of file from monitor:
possible problem:2015-12-22T21:51:20.659520Z qemu-system-x86_64: -input-linux/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd,grab-all=on:
Could not open '/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd'I also tried setting
/dev/input/event9to permissions of 666 to see if it was a permission error, but the same thing happened. Any help would be appreciated.The way I pass it is with this:
<qemu:commandline><qemu:arg value='-input-linux'/> <qemu:arg value='/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.0-event-kbd,grab-all=on'/> <qemu:arg value='-input-linux'/> <qemu:arg value='/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.1-event-mouse'/> <qemu:arg value='-input-linux'/> <qemu:arg
Quoted 7 lines
value='/dev/input/by-path/pci-0000:00:14.0-usb-0:12:1.2-event-joystick'/>
</qemu:commandline>Is there a way around this error?
Thanks,
Jon
Same here ;_;
qemu/libvirt from git (with little changes to avoid errors on build) on Arch
Greetings