[libvirt] [PATCH 1/2] Fix keymap used to talk with QEMU

Eric Blake eblake at redhat.com
Thu Aug 25 17:20:18 UTC 2011


On 08/25/2011 10:49 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange"<berrange at redhat.com>
>
> The QEMU 'sendkey' command expects keys to be encoded in the same
> way as the RFB extended keycode set. Specfically it wants extended

s/Specfically/Specifically/

> keys to have the high bit of the first byte set, while the Linux
> XT KBD driver codeset uses the low bit of the second byte. To deal
> with this we introduce a new keymap 'RFB' and use that in the QEMU
> driver
>
> * include/libvirt/libvirt.h.in: Add VIR_KEYCODE_SET_RFB
> * src/qemu/qemu_driver.c: Use RFB keycode set instead of XT KBD
> * src/util/virkeycode-mapgen.py: Auto-generate the RFB keycode
>    set from the XT KBD set
> * src/util/virkeycode.c: Add RFB keycode entry to table. Add a
>    verify check on cardinality of the codeOffset table
> ---
>   include/libvirt/libvirt.h.in  |    1 +
>   src/qemu/qemu_driver.c        |    8 ++++----
>   src/util/virkeycode-mapgen.py |   12 ++++++++++++
>   src/util/virkeycode.c         |    5 +++++
>   4 files changed, 22 insertions(+), 4 deletions(-)

> @@ -62,7 +63,10 @@ static unsigned int codeOffset[] = {
>           offsetof(struct keycode, usb),
>       [VIR_KEYCODE_SET_WIN32] =
>           offsetof(struct keycode, win32),
> +    [VIR_KEYCODE_SET_RFB] =
> +        offsetof(struct keycode, rfb),
>   };
> +extern int (*codeOffsetVerify(void)) [verify_true (ARRAY_CARDINALITY(codeOffset) == VIR_KEYCODE_SET_LAST)]; \

Why the trailing backslash?

Also, open-coding this verify is dangerous; gcc warnings have changed 
over time, rendering certain verification styles that were once safe 
into something that trips up -Werror.  It is safer (and shorter!) to let 
gnulib worry about gcc quirks, by changing this line to just be:

verify(ARRAY_CARDINALITY(codeOffset) == VIR_KEYCODE_SET_LAST);

ACK with the verify line fixed.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org




More information about the libvir-list mailing list