LWN.net Logo

Native Linux KVM tool v2

From:  Pekka Enberg <penberg-AT-kernel.org>
To:  linux-kernel-AT-vger.kernel.org, kvm-AT-vger.kernel.org
Subject:  [ANNOUNCE] Native Linux KVM tool v2
Date:  Wed, 15 Jun 2011 18:53:34 +0300
Message-ID:  <1308153214.7566.6.camel@jaguar>
Cc:  Avi Kivity <avi-AT-redhat.com>, Andrew Morton <akpm-AT-linux-foundation.org>, Linus Torvalds <torvalds-AT-linux-foundation.org>, Ingo Molnar <mingo-AT-elte.hu>, Prasad Joshi <prasadjoshi124-AT-gmail.com>, Sasha Levin <levinsasha928-AT-gmail.com>, Cyrill Gorcunov <gorcunov-AT-gmail.com>, Asias He <asias.hejun-AT-gmail.com>
Archive-link:  Article, Thread

Hi all,

We're proud to announce the second version of the Native Linux KVM tool! We're
now officially aiming for merging to mainline in 3.1.

Highlights:

- Experimental GUI support using SDL and VNC

- SMP support. tools/kvm/ now has a highly scalable, largely lockless driver
  interface and the individual drivers are using finegrained locks.

- TAP-based virtio networking

- Fast QCOW2 image read-write support beating Qemu in fio benchmarks. See the
  following URL for test result details: https://gist.github.com/1026888

- Virtio-9p support for host filesystem access in guests

- Virtio Random Number Generator

- Host block devices as in-memory copy-on-write guest images on 64-bit hosts

1. To try out the tool, clone the git repository:

  git clone git://github.com/penberg/linux-kvm.git

or alternatively, if you already have a kernel source tree:

  git remote add kvm-tool git://github.com/penberg/linux-kvm.git
  git remote update
  git checkout -b kvm-tool/master kvm-tool

2. Compile the tool:

  cd tools/kvm && make

3. Download a raw userspace image:

  Minimal:

  wget http://wiki.qemu.org/download/linux-0.2.img.bz2 && bunzip2 linux-0.2.img.bz2

  Debian Squeeze QCOW2 image:

  wget http://people.debian.org/~aurel32/qemu/i386/debian_squeez...

4. Build a kernel with the following options:

  CONFIG_VIRTIO_BLK=y
  CONFIG_VIRTIO_NET=y
  CONFIG_VIRTIO_CONSOLE=y
  CONFIG_SERIAL_8250_CONSOLE=y
  CONFIG_HW_RANDOM_VIRTIO=y
  CONFIG_FB_VESA=y

Note: also make sure you have CONFIG_EXT2_FS or CONFIG_EXT4_FS if you use the
above images.

5. And finally, launch the hypervisor:

  ./kvm run -d linux-0.2.img

or

  ./kvm run -d debian_squeeze_i386_standard.qcow2

or

    sudo ./kvm run -d linux-0.2.img -n virtio

This release was brought to you by the following people:

    Sasha Levin
    Pekka Enberg
    Asias He
    Prasad Joshi
    Cyrill Gorcunov
    Ingo Molnar
    John Floren
    Amos Kong
    Giuseppe Calderaro
    Amerigo Wang
    Paul Bolle
    David Ahern

Most of us developers are hanging out on #pvm channel at irc.freenode.net
if you want to drop by for questions, comments, and bug reports.

			Pekka



(Log in to post comments)

Native Linux KVM tool v2

Posted Jun 15, 2011 16:55 UTC (Wed) by Baylink (subscriber, #755) [Link]

Wow! A Native Linux Keyboard/Video/Mouse switchbox tool?

How cool is that?

Native Linux KVM tool v2

Posted Jun 15, 2011 22:19 UTC (Wed) by endecotp (guest, #36428) [Link]

This is the second most unfortunate kernel TLA clash after "DRM".

Native Linux KVM tool v2

Posted Jun 16, 2011 13:16 UTC (Thu) by willy (subscriber, #9762) [Link]

How about calling it 'virt' instead of 'kvm'? Seems to fit better with 'perf', as well as avoiding the namespace collision.

Native Linux KVM tool v2

Posted Jun 15, 2011 17:07 UTC (Wed) by lkundrak (subscriber, #43452) [Link]

I don't quite understand this -- it is a userspace tool, how are they going to merge that into 3.1 kernel?

Native Linux KVM tool v2

Posted Jun 15, 2011 17:10 UTC (Wed) by corbet (editor, #1) [Link]

I suspect it will go under tools/, right next to perf.

Native Linux KVM tool v2

Posted Jun 15, 2011 18:35 UTC (Wed) by PaXTeam (subscriber, #24616) [Link]

the announcement itself refers to tools/kvm so i guess that'll be the place.

Native Linux KVM tool v2

Posted Jun 16, 2011 12:27 UTC (Thu) by mingo (subscriber, #31122) [Link]


Correct, and note that tools/ is already hosting half a dozen utilities in the v3.0 kernel source:

$ ls -l tools/

drwxrwxr-x  2 mingo mingo 4096 2011-06-09 13:38 firewire
drwxrwxr-x 11 mingo mingo 4096 2011-06-16 13:26 perf
drwxrwxr-x  4 mingo mingo 4096 2011-05-30 10:23 power
drwxrwxr-x  2 mingo mingo 4096 2011-06-16 09:27 slub
drwxrwxr-x  3 mingo mingo 4096 2011-06-16 09:27 testing
drwxrwxr-x  2 mingo mingo 4096 2011-06-16 09:27 usb
drwxrwxr-x  4 mingo mingo 4096 2011-06-16 09:38 virtio

Native Linux KVM tool v2

Posted Jun 15, 2011 21:44 UTC (Wed) by aliguori (subscriber, #30636) [Link]

Ingo has made it pretty clear that he wants to move a bunch of userspace packages/tools into the kernel. There was an LWN article about a thread along these lines but the closest I can find at the moment is http://lwn.net/Articles/437114/

Native Linux KVM tool v2

Posted Jul 12, 2011 18:52 UTC (Tue) by Auders (subscriber, #53318) [Link]

<pedantic>
You mean the kernel tree. Calling it the kernel was what confused the OP.
</pedantic>

Native Linux KVM tool v2

Posted Jun 15, 2011 22:10 UTC (Wed) by aliguori (subscriber, #30636) [Link]

Hrm, I think the performance results are a bit too good to be true. Looking more closely at the code and the announcement, I can see why:

1) Native KVM tool is using virtio whereas they're launching QEMU with IDE. IDE only supports a single request at a time (this is how the hardware works).

2) Native KVM tool does not make guest data writes stable by default. QEMU does. While they do advertise the FLUSH feature, they don't advertise a write cache setting to the guest. Unfortunately, many modern guests assume storage with non-volatile write caches and don't use FLUSH's properly.

I would expect QEMU configured in the same way that Native KVM tool would be at least as good. I also would recommend that type of configuration for anyone that cared about their data as a default.

Native Linux KVM tool v2

Posted Jun 15, 2011 22:21 UTC (Wed) by aliguori (subscriber, #30636) [Link]

It's worse than I initially thought :-( Writes are unstable but FLUSH isn't currently implemented. So even if a guest does send FLUSH commands correctly, native KVM tool ignores them...

Native Linux KVM tool v2

Posted Jun 15, 2011 22:46 UTC (Wed) by aliguori (subscriber, #30636) [Link]

Nope, misread the code. It does do an fsync() on FLUSH so for guests that support barriers problem, it will work correctly.

So the behavior is equivalent to cache=writeback in QEMU.

Native Linux KVM tool v2

Posted Jun 16, 2011 6:35 UTC (Thu) by penberg (subscriber, #30234) [Link]

Yup, we worked pretty hard to make sure we don't eat your QCOW2 images for lunch :-).

Native Linux KVM tool v2

Posted Jun 16, 2011 1:30 UTC (Thu) by starlet (subscriber, #48949) [Link]

It seems that the comparison is done between Native Linux KVM and Qemu,
not between Native Linux KVM and Qemu-KVM. Right ?

Will the result be changed if the competitor is Qemu-KVM (w/ virtio) ?

Native Linux KVM tool v2

Posted Jun 16, 2011 5:39 UTC (Thu) by stefanha (subscriber, #55072) [Link]

The comparison was not between two identical virtual machines so it is not a useful comparison. See aliguori's comment above for details on configuration.

If qemu.git was used instead of qemu-kvm.git, then there are additional things that should be done to ensure the configurations are identical. QEMU needs to be configured with --enable-io-thread and invoked with -enable-kvm. Otherwise the guest will be launched in TCG (dynamic binary translation) mode instead of KVM mode. It's not clear to me whether qemu.git or qemu-kvm.git was used for the comparison yet.

Native Linux KVM tool v2

Posted Jun 16, 2011 5:41 UTC (Thu) by stefanha (subscriber, #55072) [Link]

For fairness sake I should mention that I contribute to QEMU.

Native Linux KVM tool v2

Posted Jun 16, 2011 6:30 UTC (Thu) by penberg (subscriber, #30234) [Link]

We tested kvm-qemu.git master. It turns out there are some command line options that will make Qemu perform better but we've yet to test them.

It's never going to be an apples to apples comparison but it goes to show how important _sane default values_ are. I'm willing to bet most people don't know about all the Qemu magic that makes things run faster (which is especially important for virtualized I/O).

And just to set the record straight: the only reason we did the comparison was to see how *badly* we'd compare against Qemu. Turns out we didn't do badly at all so there was no point in hiding our results - even if we have to eat our hats later on!

Disclaimer: I contribute to the tools/kvm project.

Native Linux KVM tool v2

Posted Jun 17, 2011 13:53 UTC (Fri) by aliguori (subscriber, #30636) [Link]

From Pekka:

It turns out we were benchmarking the wrong guest kernel version for
qemu-kvm which is why it performed so much worse. Here's a summary of
qemu-kvm beating tools/kvm:

https://raw.github.com/gist/1029359/9f9a714ecee64802c08a3455971e410d5029370b/gistfile1.txt

I'd ask for a brown paper bag if I wasn't so busy eating my hat at the moment.

Native Linux KVM tool v2

Posted Jun 16, 2011 6:34 UTC (Thu) by penberg (subscriber, #30234) [Link]

We tested with virtio too (we didn't realize Qemu didn't use it by default!) and while Qemu performance was little better, tools/kvm still beat it with fair margin. Unfortunately I posted the non-virtio results.

That said, don't read too much into the results. It's *one benchmark* on *one machine*. If you care about performance, you'd better benchmark things yourself. The point of publishing the results is just to show that there's some real potential in tools/kvm and that Qemu probably should improve their default configuration.

Native Linux KVM tool v2

Posted Jun 16, 2011 11:07 UTC (Thu) by stefanha (subscriber, #55072) [Link]

Although the default configuration doesn't provide optimal performance for your particular benchmark it is a conservative configuration that is safe and compatible with all sorts of guest operating systems. The scope of qemu-kvm is different from native kvm tool - it needs to run old and broken non-Linux guests in addition to supporting cutting edge guests.

qemu-kvm users normally use virt-install or virt-manager to create VMs that are configured pretty well by default. This benchmark used the raw qemu-kvm command-line without ensuring an equivalent VM configuration - not a fair benchmark.

Native Linux KVM tool v2

Posted Jun 16, 2011 15:09 UTC (Thu) by bronson (subscriber, #4806) [Link]

If it takes an hour of reading manpages and tweaking command line configs to make one version fast, and the other version is fast out of the box, then that's not a fair benchmark either.

(Not saying it does, just that your position seems oversimplified)

Native Linux KVM tool v2

Posted Jun 16, 2011 22:41 UTC (Thu) by aliguori (subscriber, #30636) [Link]

The mode the they are using is not the default in QEMU because it's faster than bare metal assuming an otherwise uncontended system with plenty of memory to burn. The results are inconsistent and the safety of doing this depends on how well behaved your guest is.

It's usually not what people want to use even if it makes for artificially high benchmarks.

Native Linux KVM tool v2

Posted Jun 17, 2011 11:41 UTC (Fri) by Darkmere (subscriber, #53695) [Link]

Frankly, even when using virt-install I'm never certain if it's the right speed or not. Mostly _io_ tends to send systems into 20+ load "wait until world peace happens" even with (supposedly?) virtio enabled.

the current state of qemu-kvm is at times, a headache to deal with.

Speeding up qemu-kvm

Posted Jun 17, 2011 22:04 UTC (Fri) by jrn (subscriber, #64214) [Link]

Based on

> Some block drivers perform badly with cache=writethrough, most notably, qcow2. If performance is more important than correctness, cache=writeback should be used with qcow2.

I switched to cache=unsafe, and life became way better. The kind of tests I do in VMs let me recreate the image if there's a sudden crash, so safety is not such a worry. Not sure if virt-install does something like that.

Native Linux KVM tool v2

Posted Jun 16, 2011 11:45 UTC (Thu) by linusw (subscriber, #40300) [Link]

This is pretty cool, and the upside looking at it from an ARM perspective is that it'll be easier to develop KVM support for the new virtualization-aware ARM Cortexes when you can build, test and integrate everything in one tree. Good work!

Native Linux KVM tool v2

Posted Jun 16, 2011 13:59 UTC (Thu) by Julie (✭ supporter ✭, #66693) [Link]

Wow. Congratulations to everyone working on this excellent tool.
For those of us for whom it's not practical to use IRC, I take it the mailing list for following it is 'kvm'?

Native Linux KVM tool v2

Posted Aug 16, 2011 7:38 UTC (Tue) by meyert (subscriber, #32097) [Link]

so what is the advantage of this tool compared to user mode linux (UML)?

Copyright © 2011, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds