What is KVM?
Kernel-based Virtual Machine, or KVM, is a virtualization technology that has been around for a decade now. It’s built into the standard Linux kernel, and is designed to enable it to act as a hypervisor. This means that pretty much any Linux distribution is ready to be used as a hypervisor once it is installed.
One downside to KVM is that it demands that the hardware it runs on has virtualization extensions. Having said that, these have now been standard in most non-Atom Intel processors and AMD processors for a number of years now, so on most systems it’s not going to be a showstopping requirement.
KVM is capable of being host for a number of guest operating systems, including various Linux and UNIX distributions, Microsoft Windows and MacOSX. Although it only provides support for virtualization of the existing system’s hardware resources, KVM is also capable of working with QEMU in order to emulate a number of pieces of common hardware for the guests, such as the Sound Blaster 16 sound card, Intel E1000 network card and Cirrus VGA graphics card to provide a fully working system. With QEMU it is also possible to provide direct USB passthrough to the guest operating system where software may make use of specific hardware or dongles.
Something else that’s handy, especially if you are considering using KVM as a way to virtualize the usage of older operating systems, is that KVM is also capable of running a 32 bit guest operating system on a 64 bit host.
While KVM provides everything needed for a virtual machine to run, it only affords a very basic interface for managing the virtual machine. A virtual machine can be run with KVM only, but it is normally combined with QEMU and other tools such as libvirt or Virtual Machine Manager which are often deployed for the management of KVM virtual machines. These tools are referred to as hypervisor managers since they control what the hypervisor does.
Once KVM is running on a Linux computer, it exposes a special device at the /dev/kvm path. This is what the intermediary tools such as libvirt use to manage the virtual machines and set them up. Being part of the Linux kernel itself means that KVM can gain direct access to the hardware on the server when managing the virtual machines. When a virtual machine is started, the hypervisor manager will communicate to KVM with regards to the resources required for the virtual machine, and KVM can then reserve the RAM required for the virtual machine, partitioning it off from that used by other virtual machines and the host operating system. Similarly, it lets KVM know how many of the CPU resources the virtual machine should be allowed, and what disk image should be loaded and referenced by the virtual machine.
For the virtual machine itself, once started KVM manages its resources transparently, so the virtual machine can be unaware that it’s even running in a virtualized environment. On the host, the running virtual machine appears much like any other running Linux process to the point that should you lose control of the operating system on the virtual machine itself, you can kill the running process on the host operating system. It will then appear from the virtual machine’s operating system’s standpoint as if the power had been pulled from a typical computer.
Something to note if you are considering playing with KVM on a machine that is already using another virtualization system: no checks are performed to see if anything else is accessing the CPU’s hardware extensions. It’s possible for two simultaneous virtualization platforms to conflict and possibly cause bad things to happen. To that end it’s best to use KVM on its own system.
For the ultimate in price and performance: configure your VPS SSD now!