Pages
Categories
Archives
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- December 2008
- November 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
Compiling kvm Under Ubuntu Edgy i386
kvm is QEMU with support for the VT Vanderpool or Virtualization Technology. This means you can now run QEMU on CPUs that have the VT instructions and you get a super quick emulated environment. Yay!
Previously to get spritely performance out of QEMU you needed the closed-source KQEMU kernel module. Now you don’t. This interests me because I use QEMU quite heavily with my little screencasting project with Ubuntu-UK. Having a totally Free (GPL) and easy to use method for running virtual machines is essential. Of course there’s Xen but kvm is a great drop-in solution with very little requirements on the host, no replacement kernels for example.
Here’s what I did on a core 2 duo CPU machine – this is on an utterly clean 32-bit Ubuntu Edgy system – I know it’s clean, I installed it last night. This assumes that you have a stock Ubuntu kernel, and not one that you have either compiled yourself or in any way patched.
If you get some output it does, if you don’t, it doesn’t. I got this:-
The important bit there being “vmx” – oh and the fact that there are two lines means it’s dual core – more yay!
You need GCC version 3.4 to compile qemu (which is included in kvm).
You should see something like this:-
(except the bit where it says “need to get 0B” will be something bigger – I cheated and already downloaded that lot)
Go get kvm from their Sourceforge download page. I saved it to my desktop because I’m messy like that.
If all goes well it should look like this:-
Note: kqemu support is “no” and kvm support is “yes”, that’s the really good stuff
You should get a boatload of “stuff” starting with:-
and finishing with something like:-
Looking good!.
At this point you can now run
qemufrom the/usr/local/kvmdirectory into which we installed it.I already have some disk images used by qemu which can of course be used by kvm also. It is based on qemu after all.
There’s more detail about qemu in a previous blog post called Creating Screencasts (down the bottom), and also on the HantsLUG wiki.
If the kvm module isn’t loaded when you start qemu then you’ll get this:-
Which is clearly bad.
If the kvm module is loaded correctly – i.e. you did everything above right then you should see this:-
And of course, here’s the obligatory screenshot
I thought I’d run a couple of benchmarks to see how it performs. I ran two. One is the amazing, nay reference gold standard benchmark that is Hugos Random Benchmark which is basically where you get a machine to count to a very big number and time it doing that. It’s great for raw clock speed pissing contests, but not much more. I should point out that the pc running this qemu/kvm image is actually top of that list. Here’s what the host gets when I run hugos random benchmark:-
alan@wopr:~$ time perl -e 'for($i=0;$i<1e8;$i++) { }' real 0m6.689s user 0m6.688s sys 0m0.000sAnd here's what the qemu/kvm image gets:-
alan@edgyvm:~$ time perl -e 'for($i=0;$i<1e8;$i++) { }' real 0m7.230s user 0m7.056s sys 0m0.032sThat looks pretty good going to me!
Ok, lets try a more sane benchmark. The UnixBench benchmark should be more like it.
Here's the result from running UnixBench on the host computer.
============================================================== BYTE UNIX Benchmarks (Version 4.1-wht) System -- Linux wopr 2.6.17-10-generic #2 SMP Fri Oct 13 18:45:35 UTC 2006 i686 GNU/Linux /dev/sdb1 235288032 30517988 192818088 14% / Start Benchmark Run: Wed Nov 15 22:10:55 GMT 2006 22:10:55 up 2:28, 7 users, load average: 0.37, 0.34, 0.23 End Benchmark Run: Wed Nov 15 22:21:25 GMT 2006 22:21:25 up 2:39, 5 users, load average: 15.93, 6.89, 3.14 INDEX VALUES TEST BASELINE RESULT INDEX Dhrystone 2 using register variables 376783.7 19976788.8 530.2 Double-Precision Whetstone 83.1 2285.9 275.1 Execl Throughput 188.3 8953.1 475.5 File Copy 1024 bufsize 2000 maxblocks 2672.0 150910.0 564.8 File Copy 256 bufsize 500 maxblocks 1077.0 40765.0 378.5 File Read 4096 bufsize 8000 maxblocks 15382.0 1234477.0 802.5 Pipe-based Context Switching 15448.6 456975.1 295.8 Pipe Throughput 111814.6 1201420.9 107.4 Process Creation 569.3 23939.3 420.5 Shell Scripts (8 concurrent) 44.8 1180.8 263.6 System Call Overhead 114433.5 3513796.1 307.1 ========= FINAL SCORE 359.3..and here we having running under qemu/kvm..
>============================================================== BYTE UNIX Benchmarks (Version 4.1-wht) System -- Linux edgyvm 2.6.17-10-generic #2 SMP Fri Oct 13 18:45:35 UTC 2006 i686 GNU/Linux /dev/hda1 9859036 1931768 7426444 21% / Start Benchmark Run: Wed Nov 15 22:34:21 GMT 2006 22:34:21 up 2 min, 2 users, load average: 1.65, 0.90, 0.35 End Benchmark Run: Wed Nov 15 22:35:20 GMT 2006 22:35:20 up 3 min, 2 users, load average: 0.67, 0.75, 0.33 INDEX VALUES TEST BASELINE RESULT INDEX Dhrystone 2 using register variables 376783.7 1.0 0.0 Double-Precision Whetstone 83.1 0.0 0.0 Execl Throughput 188.3 1.0 0.1 Pipe-based Context Switching 15448.6 1.0 0.0 Pipe Throughput 111814.6 1.0 0.0 Process Creation 569.3 1.0 0.0 Shell Scripts (8 concurrent) 44.8 1.0 0.2 System Call Overhead 114433.5 1.0 0.0 ========= FINAL SCORE 0.0Hmm. Well that's not what I was expecting, that's for sure. Answers why on a postcard.
Overall, kvm receives the "popey 5 minute test" seal of approval.