KVM Hypervisor

KVM (for Kernel-based Virtual Machine) is a fast growing open source full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V). It consists of a loadable kernel module that provides the core virtualization infrastructure and a processor specific module. Using KVM hypervisor, one can run multiple virtual machines running unmodified Linux or Windows images. Each virtual machine has private virtualized hardware: a network card, disk, graphics adapter, etc. The kernel component of KVM hypervisor is included in mainline Linux.

Considering the time line of virtualization techniques, KVM is a relative newcomer. Several incumbent open source methods exist today, such as Xen, Bochs, UML, Linux-VServer, and coLinux, but KVM is receiving a surprising amount of exposure in the press.

How hypervisor worksThe approach that KVM takes is to turn a Linux kernel into a hypervisor simply by loading a kernel module. The kernel module exports a device called /dev/kvm, which enables a guest mode of the kernel (in addition to the traditional kernel and user modes). With /dev/kvm, a VM has its own address space separate from that of the kernel or any other VM that's running. Devices in the device tree (/dev) are common to all user-space processes. But /dev/kvm is different in that each process that opens it sees a different map (to support isolation of the VMs). KVM source in the Linux kernel

KVM then simply turns the Linux kernel into a hypervisor (when you install the kvm kernel module). Because the standard Linux kernel is the hypervisor, it benefits from the changes to the standard kernel (memory support, scheduler, and so on). Optimizations to these Linux components benefit both the hypervisor (the host operating system) and the Linux guest operating systems. With the kernel acting as a hypervisor, you can then start other operating systems, such as another Linux kernel or Windows.

KVM is a unique hypervisor. The KVM developers, instead of creating major portions of an operating system kernel themselves, as other hypervisors have done, devised a method that turned the Linux kernel itself into a hypervisor. This was achieved through a minimally intrusive method by developing KVM as kernel module. Integrating the KVM hypervisor capabilities into a host Linux kernel as a loadable module can simplify management and improve performance in virtualized environments. This probably was the main reason for developers to add KVM hypervisor to the Linux kernel.

This approach has numerous advantages. By adding KVM virtualization capabilities to a standard Linux kernel, the virtualized environment can benefit from all the ongoing work on the Linux kernel itself. Under this model, every virtual machine is a regular Linux process, scheduled by the standard Linux scheduler. Traditionally, a normal Linux process has two modes of execution: kernel and user. The user mode is the default mode for applications, and an application goes into kernel mode when it requires some service from the kernel, such as writing to the hard disk. KVM hypervisor adds a third mode, the guest mode. Guest mode processes are processes that are run from within the virtual machine. The guest mode, just like the normal mode (non-virtualized instance), has its own kernel and user-space variations. Normal kill and ps commands work on guest modes. From the non-virtualized instance, a KVM virtual machine is shown as a normal process, and it can be killed just like any other process. KVM makes use of hardware virtualization to virtualize processor states, and memory management for the virtual machine is handled from within the kernel. I/O in the current version is handled in user space, primarily through QEMU.

A wide variety of guest operating systems work with KVM hypervisor, including many flavours of Linux, BSD, Solaris, and Windows Operating Systems. A modified version of Qemu can use KVM to run Mac OS X.