What is KVM?

KVM, or Kernel-based Virtual Machine, is a software feature that can be installed on Linux systems to create virtual machines (VMs). A virtual machine acts as an independent computer within another physical machine, sharing resources such as CPU, memory, and network bandwidth with the host system.

KVM is a component of the Linux kernel that has provided native virtualization support since 2007, turning any Linux machine into a bare-metal hypervisor.

Importance of KVM

KVM allows developers and system administrators to:

  • Scale computing infrastructure without new hardware.
  • Automate the provisioning of virtual environments.
  • Quickly deploy a large number of VMs, especially in cloud environments.

The main advantages of KVM include:

  • High performance: virtualization is performed close to the hardware, reducing latency.
  • Security: VMs benefit from Linux security features, including SELinux.
  • Stability: KVM has over a decade of development and support from an active open-source community.
  • Cost-effectiveness: it is free and open-source, with no additional licensing required.
  • Flexibility: supports different hardware configurations and fine-grained resource provisioning.

How KVM Works

To run KVM, the following are required:

  • A CPU that supports virtualization extensions (Intel VT-x or AMD-V).
  • An updated Linux kernel.
  • Additional components: kernel module, processor-specific module, emulator, and complementary Linux packages.

KVM Architecture

KVM is based on two main components:

  1. Kernel modules:

    • kvm.ko, kvm-intel.ko, and kvm-amd.ko.
    • Provide the virtualization infrastructure and processor-specific drivers.
  2. User space:

    • qemu-system-ARCH emulates virtual devices and manages the VMs.
    • Can be managed via QEMU tools (qemu-img, qemu-monitor) or through the libvirt stack (virsh, virt-manager, virt-install).

In practice, the term KVM is commonly used to refer both to the kernel-level functionality and the user-space component.

How VMs Run on KVM

  • VMs run as normal Linux processes on the host.
  • Each vCPU is implemented as a normal thread, managed by the Linux scheduler.
  • Advanced kernel features (NUMA, huge pages) are not automatically inherited.
  • Disk and network performance depend on host configuration.
  • Network traffic typically passes through a software bridge.
  • Emulation of specific devices may introduce additional overhead.

Differences Between KVM and VMware ESXi

FeatureKVMVMware ESXi
LicenseOpen-sourceCommercial
IntegrationLinux kernelProprietary kernel
SupportOpen-source communityProfessional support
FlexibilityHigh, fine-grained provisioningHigh, but license-dependent
EnvironmentLinuxLinux/Windows