Xen vs. KVM

Dec 20th, 2006 @ 10:15 pm CST

The news of KVM’s inclusion in the Linux kernel has me looking at KVM.

How the virtualization layer is implemented has important ramifications, and KVM is much different from Xen.

Xen itself sits directly on the hardware and treats even your old OS as a guest VM — for Xen, the Linux patches are necessary to make Linux a guest VM on the hypervisor. It implements a model known as paravirtualization that provides a lot of performance improvements over other recent x86 virtualization techniques such as VMware’s. This model includes a service VM that does privileged I/O work on behalf of the guests. (In a following entry I discuss some performance and efficiency issues, the larger story is not so simple as “paravirtualization makes everything very fast”)

Xen can also support unmodified guest VMs if you are using either a VT capable Intel processor or an SVM capable AMD processor.

KVM is a patch to the Linux kernel that is more like VServer, Solaris containers, or microkernels [see footnote], where the OS still sits directly on the hardware. Some aspects of the current KVM release (mostly pulled from their FAQ):

  • KVM guest OSs appear as a process and can be managed with top, kill, etc.
  • KVM requires either a VT capable Intel processor or an SVM capable AMD processor (which is a currently a big limitation for grid providers but this will become less and less of an issue as older clusters are phased out).
  • Uses QEMU for guest instantiation, but is not an emulator itself
  • Runs Windows 32bit already (with no apci)
  • I have yet to figure out if it relies on these kernel enhancements for OS level virtualization
  • The current implementation should probably be seen as a preview, Fraser Campbell reports that it was “decidedly slow” when he tried it.

[footnote]: Some argue that microkernels and Xen have a lot in common.

[UPDATE: This article on some KVM details was posted. Its comments also have a lot of information.]

    9 Responses to “Xen vs. KVM”

  1. Bhasker C V Says:

    And we are forgetting something major here !
    Xen is based on the bare metal and has
    no processor “emulation capabilities” whereas
    in a single processor machine, qemu can
    emulate a machine with say 4 processors !

  2. Joey Hadassah Says:

    that’s why it will never wor. Joey Hadassah.

  3. tom b Says:

    You can configure a xen virtual machine to have as many processors as you like… at least within reasonable limits. It can be more or less than the number of physical cores.

  4. Tim Freeman Says:

    The xen guest sees vcpus, these are scheduled individually onto the physical CPUs. If you have 10 times more vcpus than real ones you are going to see a lot of inefficiency but you can do it like tom b syays. You could do pathlogical tests on your concurrent code (in userspace or kernel space) — or maybe you only have a uniprocessor box and want to put concurrent code through some paces (though race conditions will not be so easily discovered because ultimately you’re still only running on a sequential uniprocessor).

    That seems to me to be the only reason to emulate more processors. Bhasker C V, I don’t know why this is “something major”?

  5. testy Says:

    Working around a slow Windows virtual machine due to ACPI

    Did you try this?
    http://kvm.qumranet.com/kvmwiki/Windows_ACPI_Workaround

    If your Windows installation is set to use ACPI (this is the default), kvm can be quite slow or not work at all. This is due to Windows heavily using a register that has a very large virtualization penalty.

    Fortunately, there is a simple workaround available: disable ACPI support in Windows. The procedure for doing this is:

    Select “My Computer” with the right mouse button.
    Select “Properties”.
    Choose the “Hardware” tab.
    Click the “Device Manager” button.
    Select the entry under “Computer” with the right mouse button. If it says “Standard PC”, then there’s no need to do anything.
    Select “Properties”
    Click the “Update Driver” button.
    Choose “No, not this time” and click “Next”.
    Choose “Install from a list” and click “Next”.
    Choose “Don’t search” and click “Next”.
    Click “Next”.
    Choose “Standard PC” and click “Next”.
    Continue clicking “Next” and reboot the virtual machine.
    If you’re installing Windows XP/2000, you can get it to use the Standard PC HAL by pressing F7 when it asks for drivers (”Press F6 for…”), there is no visual indication. If you would rather select the right HAL from a list visually then press F5 instead.

  6. vidyadhara Says:

    my head reels. cant quite figure out which virtualization path to take for my little home office.
    I am doing no business now a days other than figuring out virtualization and suffering the effects. :)

  7. Tim Freeman Says:

    VMware player/server is a convenient way to go for home setups, IMO. Differences in performance/features is not really applicable there, may as well go with something easy to use and that has a lot of pre-made VMs, templates, etc.

  8. Rolf Ernst Says:

    I tried KVM under Ubuntu Hardy and ran into a number of problems with the graphical interface to configure the machine, lacking many command line options, most notably the one to disable acpi.

    Once I configured the machine via command line on a VT enabled AMD with one processor, Windows definitely performed very well, notably better than Virtualbox. Since I only defined one VCPU it was certainly much, much slower than then native machine. When I installed with 2 VCPUs the machine crawled, similar to an initial acpi installation I had done which took somewhere in the neighborhood of 12 hours.

    I used an sdl display configuration which performed reasonably well, obviously lacked 3d support of any kind (the OpenGL support floating around is more or less of a ummh, joke, considering it does not support shaders) and maxed out at 1280×1024 at 16 bit. Virtualbox will pretty much do whatever you ask it to.

    Thus, once again, I went native Windows for my heavily multithreaded Adobe A/V applications, with no Linux equivalent.

    I fail to see any truly feasible Desktop virtualization solution at this point. As for server virtualization, I would consider KVM ready for prime time if you don’t need multiprocessors per machine.

  9. Enzo Says:

    Xen is kind of a disaster too. I’ve set it up with Fedora 8, but Fedora 9 or 10 doesn’t support Xen as a domU guest.

    But I’m using Xen 3.1, the 3.3 kernel doesn’t seem to boot at all. The 3.1 xen kernel i’ve found that the guest oses sometimes lockup and cannot be destroyed or shutdown at all and won’t restart. The xen docs suck ass. They have URLs listed that don’t even work and it is a pain to setup a domU as you need valid media install urls for the guest host you want to install. Good luck tracking those down for centos, ubuntu, freebsd, etc.

    I’ll try OpenVZ next and then KVM.