KVM - The informations you may be missing
Good morning Ubuntu, we are together today to try to help people who want to deploy KVM. Ubuntu Hardy being the latest LTS version of Ubuntu, it is a good choice for people like me who don't want to spend time upgrading every 6 months. On the other hand, there are some issues with KVM on it - so let's work around them!
Short howtos
You should use the e1000 network NIC (really)
Using the default network NIC, I have noticed tiny but highly annoying ethernet errors. Run a ifconfig -a:
RX packets:50916071 errors:24 dropped:27 overruns:0 frame:0 TX packets:4185949 errors:0 dropped:0 overruns:0 carrier:0
Oups! That may be the reason why the md5 of some of the isos I copy sometimes don't match. Sooo - I moved to virtio for my network. With not so much more success - virtio seems very unhappy with large file transfers, and the driver would just crash, leaving the VM without connectivity. Not great - luckily the e1000 seems to work fine so far.
So, run "virsh dumpxml virtualmachine" - copy the result and paste it into a new file, the name doesn't really matter. Open that file and look for the section with the interface, where you will add the "model" line:
<interface type='bridge'>
<mac address='00:16:3e:00:50:19'/>
<source bridge='br0'/>
<model type='e1000'/>
</interface>
Now, run "virsh define thefile" and restart the VM. Should be much better 
The VMs don't start automatically when the host starts. But they could!
A trick found thanks to virt-manager and to the help of people on #ubuntu-virt. Go to /etc/libvirt/qemu/, and there create a folder called "autostart". There, make a softlink to the XML files of the vms you want to start automatically:
cd /etc/libvirt/qemu/ sudo mkdir autostart sudo chmod 755 autostart cd autostart sudo ln -s /etc/libvirt/qemu/virtualmachine.xml virtualmachine.xml
And that should do the job.
Get Windows XP/2000 to run
Slightly tricky. Forums are full of questions about that... Use the Qcow2 file format! Sadly virt-install doesn't have any way to specify the file format (at least in ubuntu Hardy) - so let's start with a normal creation of a VM:
cd /var/lib/kvm/
sudo virt-install --connect qemu:///system -n vm -r 1024 -f vm/windows -s 20 -c /home/yann/win2Kserver.iso --vnc --noautoconsole --os-type windows --os-variant win2k
Then, we quickly stop the VM while it boots *cough* : virsh destroy vm - and convert the image to qcow2:
cd /path/to/your/image sudo qemu-img convert windows -o qcow2 windows.qcow2
There are also some tweaks we will need to do to the XML definition of the file. So, as previously, run "virsh dumpxml virtualmachine" and paste the result in a file. There, update the path of the disk:
<source file="/path/to/your/vm/windows.qcow2" />
Update the network NIC to e1000 (see previous section), and add a link to the cdrom (windows reboots after the formatting part, and can't find its cdrom anymore as virt-install attachs the cdrom only for the first boot).
[...]
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
<source file='//home/yann/win2Kserver.iso'/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
"virsh define file", and "virsh start vm". You should now be able to install windows XP and 2000 (didn't test other versions) without problems!
And some news...
Spice-up your remote desktop
Sorry for the ugly title
So, at the moment, we use VNC to connect to our KVM virtual machines. Let's admit it: VNC's performances suck. When Qumranet developped KVM, they also developped a proprietary alternative to VNC called SPICE. The interesting bit is that now that Redhat has bought Qumranet, they want to make it opensource, and apparently it's planned to happen pretty soon. Here is the interesting interview. I've been looking at alternatives to VNC for months, and beyond NX and its single implementation, I've not been very successful - so huge hopes from me on that side.
Some more links for those with real interest
Shamelessly copied from an interesting article on linuxfr.org:
- Red Hat Sets Its Virtualization Agenda
- Red Hat Announces Broad ISV Ecosystem is Virtualization-Ready
And Ubuntu?
As Redhat is owning KVM, they are the best place to look for shiny news... But regarding Ubuntu, I heard the current buzzwords were Eucalyptus and Open nebula. Haven't really had time to try any of these yet - would be incredibly grateful for feedback on them 
That's all for today - as a strong KVM supported I'd be happy to reply to questions and queries related to it in the comments. Thanks for reading 
Spice *and* SolidICE are planned to be open :
http://fedoraproject.org/wiki/Qumranet
> I heard the current buzzwords were Eucalyptus and Open nebula.
Open nebula is interesting. But Ovirt is very interesting : http://ovirt.org/
Posted by web123 on February 24, 2009 at 04:43 PM GMT+00:00 #
! I didn't know they were thinking about making solidice open... This is big news for me, thanks for the link :)
Posted by Yann on February 24, 2009 at 04:52 PM GMT+00:00 #
I am also very excited about SolidICE this is something that I have needed for quite some time.
Posted by sharms on February 24, 2009 at 06:04 PM GMT+00:00 #
If Canonical only supports KVM officially in Ubuntu Server as a part of main, Eucalyptus doesn't necessarily make a lot of sense as a project to highlite as its a research project which requires Xen and does not yet support KVM in its public releases. It's going to be introduced in version 1.5, which doesn't even have any testing releases out.
The group states clearly that this is still a very early development project, so much so that they don't currently accept major external contributors. If they aren't prepared to accept help yet from Canonical, is this really far enough along for Shuttleworth to make a big deal about and ramp up interest in? I think Shuttleworth does a disservice to the academic project by raising the interest level beyond what the project is prepared to currently handle.
-jef
Posted by Jef Spaleta on February 24, 2009 at 06:45 PM GMT+00:00 #
Were the RX errors specific to Hardy?
I'm using virtio with Intrepid hosts and guests error free.
Posted by Karl Bowden on February 24, 2009 at 09:18 PM GMT+00:00 #
First of all, your blog is 'broken'. After I typed my story and pressed post, I was told my comment was marked spam because it was longer than 1000 characters. If it can't be longer than 1000 characters, use the appropiate attributes for the input fields. Anyway, I'll split my post up so here it is in 3 comments:
Posted by Michael Croes on February 24, 2009 at 09:53 PM GMT+00:00 #
"You should use the e1000 network NIC (really)"
Only if you want to. From reading your post I get the impression this is your first day with KVM. Either way, there's no need to use e1000, and I can actually tell you why you *shouldn't* use e1000. I personally use virtio and rtl8139. I started with rtl8139 because it was the default (and defaults tend to be sane), but soon moved to virtio_net for my linux guest. There's no hassle in setting it up, so for me there's no reason not to use it. I don't have any issues with it either, so maybe your machine has issues, or your install (or distribution) has issues somewhere. I do have to say I'm not using an old version of KVM (8.04 is nearly a year old, so the KVM in 8.04 should be a year old too...)
Posted by Michael Croes on February 24, 2009 at 09:53 PM GMT+00:00 #
When I started with running FreeBSD as guest I also started out by using the rtl8139 nic, just because it's a sane default (for freebsd too). I moved to e1000 for a short period, but somehow the e1000 nic has (or had) issues with multicast traffic, so avahi isn't working with e1000 nics in freebsd (or wasn't, there was a fix related to multicast in KVM-84 for the e1000 driver, but I haven't tested it yet). So for FreeBSD I still use the rtl8139 nic. When I added another FreeBSD install last week (so I have 1 Linux guest, 2 FreeBSD guests) that I used e1000 for, I actually started getting lockups. Not every process would lock up, but it seems everything related to networking would die. I haven't investigated that problem much either, but it definately seems related to the use of the e1000 nic.
Posted by Michael Croes on February 24, 2009 at 09:54 PM GMT+00:00 #
Last but not least there's no reason to use e1000 in windows either, because there are virtio drivers for windows too. All in all, there's no reason why I should use the e1000 nick for my guests, so next time, don't tell people they should unless it's true...
Posted by Michael Croes on February 24, 2009 at 09:54 PM GMT+00:00 #
Hello Michael, thanks for your comment, but I have to disagree :) If you look at the very first paragraph of my post:
"On the other hand, there are some issues with KVM on it - so let's work around them!"
This post is about KVM specifically on Ubuntu 8.04, and having used KVM for a while, I can tell you: there are issues with virtio and rtl8139. Even better, this bug has been identified yesterday by kirkland and solved in that patch: https://launchpad.net/%7Ekirkland/+archive/ppa/+files/kvm_62+dfsg-0ubuntu9~ppa1_i386.deb . Of course this issue has a large chance to occur only on Ubuntu Hardy. See this bug: https://bugs.launchpad.net/ubuntu/+source/kvm/+bug/332156 . E1000 is, *on hardy*, the only nic that I found to be working properly so far.
Happy to hear this is all solved in intrepid, sadly it is not the version I am using, neither the version this post was targeted to :) I will look into the blog length limit though, surely you should be allowed to post longer posts.
Posted by Yann on February 25, 2009 at 11:25 AM GMT+00:00 #
Dear Yann,
I have same problem like you when I use the default driver. But after I changed to e1000, the snmp that I use to graph the traffic is always result zero traffic. Are you experienced the same with snmp?
FYI, my KVM is using Hardy too.
--budiw
Posted by budiw on February 26, 2009 at 07:27 AM GMT+00:00 #
Hello budyw, can you try that package I linked into my previous post? It apparently fixes both virtio and default rtl8139 (although I only tested with virtio).
Posted by Yann on February 26, 2009 at 02:52 PM GMT+00:00 #
Dear Yann, Thanks for the suggestion. I'll try it.
Posted by budiw on February 27, 2009 at 11:31 PM GMT+00:00 #
Dear Yann, Looks like that package is for PPA Architecture. I'm using x86_64. Is there any similiar package but for x86_64 architecture?
--budiw
Posted by budiw on February 28, 2009 at 04:12 AM GMT+00:00 #
Oops, What I mean is, the package architecture is for i386, but my server is x86_64.
--budiw
Posted by budiw on February 28, 2009 at 04:16 AM GMT+00:00 #
Oops again. :D
Looks like on Kirkland is also available the patch for amd64.
Thank you.
--budiw
Posted by budiw on February 28, 2009 at 04:40 AM GMT+00:00 #