A While ago, a customer of ours complained about the keyboard layout not working correctly in a KVM/Qemu guest when connecting with the virt-manager console view. And so… I started investigating.

In KVM/Qemu there’s a configuration option which allows you to set the keyboard layout (virsh edit virtual-guest-name):

	<graphics type='vnc' port='5902' autoport='no' listen='0.0.0.0' keymap='en-us'/>
	

The customer was using an azerty(fr-be) keyboard layout so I decided to correct the value in this configuration:

	<graphics type='vnc' port='5902' autoport='no' listen='0.0.0.0' keymap='fr-be'/>
	

Sadly, the keyboard would still not work correctly, the layout for normal keys seemed correct, as the virtual guest spit out ‘azerty’ in a notepad when actually typing ‘azerty’, BUT it seemed that other characters, like ‘@#$\/’ etc did not work.

To make sure, I checked bot the Red Hat virtualisation host and guest if the keyboard was set correctly with ‘system-config-keyboard’. They were set correctly… I had no Idea what to do next, so I started investigating and lurking around on the net. After lots and lots of searching I stumbled upon a lot of bugreports for KVM, Xen, and virt-manager all claiming keymap issues and some claiming to have worked around it by adding the keymap=’…’ option. I figured, while this not worked for me, I might try just losing the keymap=’…’ option like so:

	<graphics type='vnc' port='5902' autoport='no' listen='0.0.0.0' />
	

Surprisingly, this worked, and the keyboard now worked correctly inside the guest, while using the virt-manager console. Yeah! It seems to be related to faulty keycode conversion by the virt-manager VNC console.

One more problem was left though, as Alt Gr did not seem to work, but this problem proved to not be virt-manager or KVM related, as the virtualisation host did not pick up on AltGr either. This seems to be a bug in NXClient < 3.3.x.

So, are you using a non- en-us keyboard with and you use the virt-manager console? Make sure both the virtualisation guest and host are using the right keyboard layout, and OMMIT the ‘keymap=’ option from the KVM/Qemu configuration.

Using NXServer? Update your client!

/dev/out