[libvirt-users] Keyboard problems with VNC access

Daniel P. Berrangé berrange at redhat.com
Wed Jan 30 12:32:41 UTC 2019

On Fri, Jan 25, 2019 at 04:35:12PM +0000, Nick Howitt wrote:
> Hi,
> I am pretty new to libvirt, but have succeeded in setting up two VM's,
> Windows 10 and ClearOS (a Centos derivative) and they both have the same
> issue. I have installed both of them with a UK English keyboard, but the
> host machine is remote and in the US with a US locale. When I access either
> through VNC (I've tried TightVNC and VNC-Viewer), a number of my keys don't
> map correctly. As an example the \ key comes up with a #, and the # key
> comes up with a 3 (as does the 3 key). Other keys are the standard US type
> of mapping, but the £ (above 3) comes up blank and the $ (above 4) comes up
> with $ which, I think is the UK setting and not the US setting. At this
> point I am thoroughly confused.
> Does anyone have any ideas?

With the traditional VNC protocol, key presses are as key symbols which
means your local client key map conversion has already been applied. When
QEMU injects keys into the guest OS, it has to undo this key map conversion
to get the scancodes again.  This undo is a lossy procedure unless the
keymap in your VNC client machine 100% matches the keymap used by QEMU.
For sanity the guest OS keymap also has to match or it will convert the
scancodes it gets from QEMU back into different key symbols.

NB, QEMU does not use its host OS keyboard layout -  it uses the layout
given by the "-k" argument to QEMU, which defaults to "us" if not specified.

This is likely the problem you are facing since you say the VMs have
UK keyboard layout and your QEMU is probably using US layout  and so
is your client machine.

QEMU defined a VNC protocol extension which allows the client  to pass
raw scancodes to QEMU. This avoids the need for QEMU todo any lossy
conversion, as it can send them straight to the guest OS.

This extension is supported by the GTK-VNC library used by virt-manager,
virt-viewer, GNOME boxes, and Vinagre clients. I believe the extension
is also supported by TigerVNC, and the HTML5  noVNC web client (though
that has plenty of other pain with keyboards).

If you have a client that supports this extension, then you must make
sure that *no* -k arg is gievn to QEMU.

|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

More information about the libvirt-users mailing list