Lately I have been playing around with KVM, meaning the Kernel-based Virtual Machine for Linux. It is by far the fastest virtual machine that i have seen running on Linux. And you have to thank the Open Source world, for providing yet another great piece of software, and this in fact allows me to take advantage of my Virtual Technology enabled Intel hardware. I have been windows free for sometime now, and for work i have been using Virtual Machines when required, but now that is not a pain as it once was… But once i got through windows, here is what I have running:
- Windows XP
- Ubuntu Gutsy Gibbon
- OpenBSD 4.1
- All the live cd’s i can get my hands on (and most of them actually boot)
I do my bleeding edge developing on Ubuntu Gutsy, meaning Ubuntu packages mostly, without breaking my own system, which is rather nice, since i need my machine to work. Other than that i finally took OpenBSD for a spin since i can spare the space and the time, and its quite fast under KVM.
Having said that, what would I like to virtualize next ? MAC OS X definitely, since i am eager to start using Omnigraffle on a regular basis.
What I would like to have next on KVM ? Here is my whishlist:
- Graphic hardware driver for the emulated card (a cirrus) that adjusts the virtual machine resolution to the window size, allowing on the fly window resize and virtual machine resolution change (a la VMWare)
- Easier integration of network configuration. I currently use tap devices, with NAT on the host machine. This is fine, but is not very user friendly. I have to give virt-manager a go to see if it helps in this point.
And finally a little Networking HOWTO for KVM:
I will skip setting up an image and installing a OS. You can find that on KVM Howto available from the KVM Wiki. It’s pretty simple:
- Setup an Image
- Boot an ISO with KVM (or qemu, depending on which boots)
- Run the new image
I’m concerned with the networking part, which i didn’t find that simple to get working.
First, check that you have tunctl
sudo apt-get install uml-utilities
Next comes network scripts to replace the kvm one’s that I couldn’t quite figure out.
We need NAT from the main device to the tap interface:
#!/bin/bash #load iptables and natsudo modprobe ip_tables sudo modprobe iptable_nat #enable forwarding echo "1" | sudo tee /proc/sys/net/ipv4/ip_forward #load rules sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
Now the actual script that brings up the tap0 interface. This is called by kvm on startup:
#!/bin/bash IFNAME=tap0 sudo ifconfig $IFNAME 192.168.100.1 netmask 255.255.255.0 up
Then, finally, a generic script to bring up everything:
#!/bin/bash # Device used in the other scripts IFNAME=tap0 #load kvm modules, intel in my case sudo modprobe kvm-intel sudo modprobe tun # start kvm sudo kvm -hda ubuntu-feisty.img -boot c -m 384 \ -net nic -net tap,ifname=$IFNAME,script=./net.sh
This brings up the Ubuntu Feisty image I had previously setup.
Enjoy.
