Re: [PATCH v3 00/29] ui/input: Decouple internal and QAPI input events

2026-05-20 Thread marcandre . lureau
On Wed, 20 May 2026 15:47:43 +0900, Akihiko Odaki 
 wrote:
> ui/input: Decouple internal and QAPI input events
> 
> The internal input event representation has different requirements from
> the QAPI representation. Using QAPI types directly spreads QAPI-specific
> constraints throughout the internal input code. Keep that impact
> localized by decoupling the two representations with a dedicated
> conversion layer. The decoupled internal representation has the
> following benefits:
> 
> [...]

Reviewed-by: Marc-André Lureau 

-- 
Marc-André Lureau 




[PATCH v3 00/29] ui/input: Decouple internal and QAPI input events

2026-05-19 Thread Akihiko Odaki
The internal input event representation has different requirements from
the QAPI representation. Using QAPI types directly spreads QAPI-specific
constraints throughout the internal input code. Keep that impact
localized by decoupling the two representations with a dedicated
conversion layer. The decoupled internal representation has the
following benefits:

- It avoids wrapper structs and pointer indirections required by QAPI.
  They are useful at the QMP boundary, but unnecessary for internal
  input events and make handlers more verbose.

- It enforces a single key code set while QAPI input events allow key
  codes to be stored either as qnum or qcode. Having two code sets is
  useful for QMP compatibility, but complicates internal input handling.
  Commit af07e5ff02ae ("ui: convert key events to QKeyCodes
  immediately") made qcode the only key code set used internally, but
  the QAPI type does not enforce that and accessing the key code is
  still tedious.

- It uses Linux key codes. They cover all keys represented by qcodes,
  include additional keys, and allow QEMU to pass codes through from
  Linux hosts to Linux guests. This also simplifies the code by avoiding
  qcode aliases and matches the approach used by virtio and Xen. Since
  this is an internal representation, QEMU can extend the key code set
  if a QEMU-specific need arises.

Only the switch to Linux key codes is intended to change functional
behavior. The interfaces that require QKeyCode are still preserved and
QKeyCode_str() is still used to query key names. Changing QAPI to accept
Linux key codes is possible, but out of scope for this series.

This series is organized as follows:
Patches 1-6 convert the internal interfaces.
Patches 7-26 convert their users.
Patches 27-28 remove the old internal interfaces.

Signed-off-by: Akihiko Odaki 

---
Changes in v3:
- Fixed qemu_input_event_send_key_number() to send the converted Linux key
  code directly.
- Updated tools/qemu-vnc for the input event API changes.
- Prevented ui/kbd-state from reading or writing past its key bitmap
  when given a key code outside the defined range.
- Changed Linux key code variables to use unsigned int.
- Link to v2: 
https://lore.kernel.org/qemu-devel/[email protected]

Changes in v2:
- Fixed an accidental overwrite of the key value in patch
  "ui/input: Remove QAPI wrappers from QemuInputEvent".
- Added patch "ui/input: Prohibit sending KEY_RESERVED".
- Removed remaining unintended QKeyCode occurrences.
- Link to v1: 
https://lore.kernel.org/qemu-devel/[email protected]

To: [email protected]
Cc: Marc-André Lureau 
Cc: Paolo Bonzini 
Cc: Jan Kiszka 
Cc: Peter Maydell 
Cc: Stefano Stabellini 
Cc: Anthony PERARD 
Cc: "Edgar E. Iglesias" 
Cc: Mark Cave-Ayland 
Cc: "Michael S. Tsirkin" 
Cc: Gerd Hoffmann 
Cc: Thomas Huth 
Cc: Alex Bennée 
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: Philippe Mathieu-Daudé 
Cc: Akihiko Odaki 

---
Akihiko Odaki (29):
  ui/input: Introduce QemuInputEvent typedef
  ui/input: Remove QAPI wrappers from QemuInputEvent
  ui/input: Store QKeyCode directly in QemuInputKeyEvent
  ui/input: Use Linux key codes for internal key events
  ui/input: Prohibit sending KEY_RESERVED
  ui/console: Add qemu_text_console_put_linux()
  ui/kbd-state: Use Linux key codes
  hw/arm/musicpal: Use Linux key codes
  hw/char/escc: Use Linux key codes
  hw/display/xenfb: Use Linux key codes
  hw/input/adb-kbd: Use Linux key codes
  hw/input/hid: Use Linux key codes
  hw/input/ps2: Use Linux key codes
  hw/input/virtio-input: Use Linux key codes
  hw/m68k/next-kbd: Use Linux key codes
  replay: Use Linux key codes
  ui/cocoa: Use Linux key codes
  ui/dbus: Use Linux key codes
  ui/gtk: Use Linux key codes
  ui/input-barrier: Use Linux key codes
  ui/input-legacy: Use Linux key codes
  ui/input-linux: Use Linux key codes
  ui/keymaps: Use Linux key codes
  ui/sdl2: Use Linux key codes
  ui/spice: Use Linux key codes
  ui/vnc: Use Linux key codes
  qemu-keymap: Use Linux key codes
  ui/console: Remove qemu_text_console_put_qcode()
  ui/input: Remove unused QKeyCode helpers and keymaps

 include/qemu/typedefs.h  |   1 +
 include/system/replay.h  |   2 +-
 include/ui/console.h |   3 +-
 include/ui/input.h   |  92 --
 include/ui/kbd-state.h   |  12 +-
 replay/replay-internal.h |   6 +-
 ui/x_keymap.h|   3 +-
 chardev/msmouse.c|  12 +-
 chardev/wctablet.c   |  10 +-
 hw/arm/musicpal.c|  31 +++--
 hw/char/escc.c   |  45 +++
 hw/display/xenfb.c   |  51 +++-
 hw/input/adb-kbd.c   | 246 ++--
 hw/input/adb-mouse.c |  22 ++--
 hw/input/hid.c   |  41 +++---