As of Qemu 0.10.0 support for KVM is included. This is available in Arch Linux simply by installing the “qemu” package. Add yourself to the kvm group and make sure the kernel modules are loaded.
modprobe tun bridge
Then pick one:
modprobe kvm-intel modprobe kvm-amd
Install required packages:
pacman -S uml_utilities bridge-utils
Skip using dynamic networking scripts and do stuff manually:
echo '#!/bin/sh' >/etc/qemu-ifup chmod 755 /etc/qemu-ifup echo '#!/bin/sh' >/etc/qemu-ifdown chmod 755 /etc/qemu-ifdown
Set up the bridge:
tunctl -u USER -t virt0 brctl addbr br0 ifconfig eth1 0.0.0.0 promisc up ifconfig virt0 0.0.0.0 promisc up brctl addif br0 eth1 virt0 ifconfig br0 192.168.1.1 up
Turn off the bridge:
ifconfig br0 0.0.0.0 down brctl delbr br0 ifconfig virt0 down ifconfig eth1 down tunctl -d virt0
Create a file system image:
qemu-img create -f qcow2 FILENAME 10G
Linux guests work well with this:
qemu-kvm -m 512 -net nic,model=e1000 -net tap,ifname=virt0 \ -usb -usbdevice tablet -drive file=FILENAME -cdrom /PATH/TO/INSTALL.ISO
Note: Windows XP guests don't like the e1000 NIC, so just remove model=e1000 if you have trouble with networking after install.
My goal was to set up KVM as a replacement to Xen on headless servers; I prefer VirtualBox for interactive desktop operating systems. Terminal access is preferable to VNC or SDL access mostly for performance and accessibility reasons. This set up is required for the guest operating system.
In /boot/grub/menu.lst add to the top:
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 terminal --timeout=10 serial console
This will make grub wait 10 seconds for a response on serial before falling back to normal VGA output. Also, I believe speed 115200 will fall back to 9600 if it's unsupported.
Also in /boot/grub/menu.lst append to the end of the kernel line:
console=tty0 console=ttyS0,115200n8
This will get you boot output on the serial port but wont let you log in. For that you need to modify tty settings which differ depending on distribution of the guest operating system.
First check /etc/securetty and add ttyS0 if it's not there:
grep ttyS0 /etc/securetty
Note: I haven't tested this yet.
Add to /etc/inittab
T0:123:respawn:/sbin/agetty -L ttyS0 115200 vt100
Edit or create /etc/event.d/ttyS0
# ttyS0 - getty # # This service maintains a getty on ttyS0 from the point the system is # started until it is shut down again. start on runlevel 2 start on runlevel 3 start on runlevel 4 start on runlevel 5 stop on runlevel 0 stop on runlevel 1 stop on runlevel 6 respawn exec /sbin/getty 115200 ttyS0
You should now be able to start your Linux guests like so:
qemu-kvm -m 512 -net nic,model=e1000 -net tap,ifname=virt0 -drive file=FILENAME -nographic
and output should go right to the terminal! This works well with GNU Screen.