Keymap Problems with Virt-Manager
So here's the problem:
I'm trying to use an Ubuntu 8.04.3 (Hardy) machine as a host for some KVM virtual machines. The Ubuntu server is headless and my management client is an Apple MacBook with Mac OS X 10.5.8 and the X11 server installed.
The basic steps I use to manage the virtual machines are (executed on the Macintosh):
Start X11
In the xterm connect to the Ubuntu machine with ssh (enabling X11-Forwading):
ssh -X ubuntu.local
Open virt-manager by typing:
sudo virt-manager -c qemu:///system
Up to this step everything works and I get a virt-manager window on my OS X machine.
The real pain begins after connecting to the graphical console of a virtual machine: Every key on my keyboard (an apple keyboard with german layout) results in something completely wrong in the VM. For example pressing Return on my keyboard results in a lowercase j in the VM, t maps to w, 9 maps to - and so on. After some time I discovered that the number 8 is interpreted as Return ...
Addtionally it is not possible to press CRTL+ALT to leave the graphical
console. This can be easily fixed on your Mac by creating a file in your
Home directory (~
) called .Xmodmap
with the following content:
clear Mod1 keycode 66 = Alt_L keycode 69 = Alt_R add Mod1 = Alt_L add Mod1 = Alt_R
Luckily I found this snippet in peter's blog.
But this doesn't solved the original problem with the completely b0rked keyboard layout in the VNC session opened by virt-manager. After some time I was able to resolve it with the following method (Everything done on the Ubuntu machine - the KVM host):
Create a file
/usr/local/bin/kvm
with the following contents:#! /bin/bash exec /usr/bin/kvm -k de "$@"
Be sure to replace
de
with whatever keyboard layout you are using on the client machine.The path and name of the file is not important, it just has to match the one used in the next step. Be sure NOT to overwrite your
kvm
binary in/usr/bin
.In the config of your virtual machine (has to be done for every VM), which can be found at
/etc/libvirt/qemu/<name>.xml
modify the following line:# old: <emulator>/usr/bin/kvm</emulator> # new: <emulator>/usr/local/bin/kvm</emulator>
Restart libvirtd with
/etc/init.d/libvirt-bin restart
The small wrapper, in this example saved as /usr/local/bin/kvm
appends
the option -k de
to kvm (which is basically just qemu) and therefore
instructs qemu to start the VNC server for the virtual machine with the
keymap de
. You still have to configure the correct keyboard layout
in the Operating System of the VM, but at least my keyboard now sends the
correct keys to the VM through SSH+X11+VNC ...
Didn't work for me in Ubuntu 10.04, the KVM just complained about a missing Qemu version. However, a surprising and easy fix did the thing,
alias kvm=kvm -k fi
In my case the keymap was fi, but replace with the keymap of your preference. After this, restart libvirt-bin (in 10.04 ubuntu)
stop libvirt-bin
start libvirt-bin
And the keys work as expected. Probably messed up at next boot though, so need to find a place to store that in a more permanent way.
Geschrieben von Malkus Lindroos 5 Monate, 3 Wochen nach Veröffentlichung des Blog-Eintrags am 24. Sept. 2010, 15:06. Antworten
Thanks so much for this, I was struggling with this for awhile.
I was also running Unbuntu 10.04 on the host OS and trying to access my VM's from a Mac.
For me I had to do, to enable the US keyboard.
alias kvm='kvm -k en-us'
Geschrieben von Jason Shueh 6 Monate nach Veröffentlichung des Blog-Eintrags am 30. Sept. 2010, 01:17. Antworten
You can pass a keymap to vnc through libvirt as well:
http://blog.loftninjas.org/2010/11/17/virt-manager-keymaps-on-os-x/
Geschrieben von Bryan McLellan 7 Monate, 2 Wochen nach Veröffentlichung des Blog-Eintrags am 18. Nov. 2010, 04:15. Antworten
Yes, but IIRC not in the old libvirt version on Ubuntu 8.04.x.
Geschrieben von Arne 7 Monate, 2 Wochen nach Veröffentlichung des Blog-Eintrags am 18. Nov. 2010, 09:10. Antworten
I struggled with this for a few day before I messed with the graphical VNC settings. using a mac with ssh xll and vnc I was able to map the keys by powering off the vm, removing the graphics hardware profile (display VNC). I then re-added it with the key mapping of "en-us" this has worked great for all of my VM's, including windows and other graphical operating systems being access via a mac.
Geschrieben von kevin 10 Monate, 2 Wochen nach Veröffentlichung des Blog-Eintrags am 13. Feb. 2011, 02:34. Antworten