Home

KVM (Kernel-based Virtual Machine)

Open-Source Linux Virtualization Technology

Welcome to KVM

KVM (Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V). It consists of a loadable kernel module (kvm.ko) that provides the core virtualization infrastructure and processor-specific modules (kvm-intel.ko or kvm-amd.ko).

As part of the Linux kernel since version 2.6.20, KVM has become the de facto standard for Linux virtualization, powering everything from small development environments to massive cloud infrastructures like OpenStack and enterprise data centers.

What is KVM?

KVM transforms the Linux kernel into a Type-1 (bare-metal) hypervisor. When the KVM kernel module is loaded, Linux becomes a hypervisor capable of running multiple isolated virtual machine environments. Unlike traditional hypervisors, KVM leverages existing Linux kernel features for memory management, scheduling, and hardware drivers.

KVM requires hardware virtualization support (Intel VT-x or AMD-V) to operate. It provides near-native performance by executing guest code directly on the CPU through hardware-assisted virtualization, intervening only when necessary for I/O operations or privileged instructions.

Key Characteristics

  • Kernel Integration: Built into the Linux kernel mainline
  • Hardware Requirements: Requires Intel VT-x or AMD-V CPU extensions
  • Open Source: GPL-licensed with active community development
  • Full Virtualization: Run unmodified guest operating systems
  • Performance: Near-native performance using hardware acceleration
  • Platform Support: x86, ARM, PowerPC, s390 architectures

History and Development

KVM was originally developed by Qumranet, a startup founded in 2005. The project was released as open-source software in October 2006 and was merged into the Linux kernel mainline in version 2.6.20 (February 2007), making it one of the fastest kernel inclusions for a major feature.

Red Hat acquired Qumranet in 2008 for $107 million and has since been the primary sponsor and maintainer of KVM. The acquisition solidified KVM's position as Red Hat's strategic virtualization technology, replacing Xen in Red Hat Enterprise Linux 6.0.

Core Components

KVM Kernel Module

The core hypervisor component:

  • kvm.ko - Core KVM infrastructure
  • kvm-intel.ko - Intel VT-x support
  • kvm-amd.ko - AMD-V support
  • CPU virtualization management
  • Memory management interface
  • I/O interception and handling

QEMU

User-space device emulation:

  • Hardware device emulation
  • BIOS and firmware
  • Disk image management
  • Network device emulation
  • USB and peripheral support
  • Monitor interface for control

libvirt

Virtualization API and management:

  • Unified API for hypervisors
  • XML-based VM definitions
  • Network and storage management
  • Remote management support
  • Security and access control
  • Integration with tools

virtio

Paravirtualized I/O framework:

  • High-performance network I/O
  • Block device optimization
  • Reduced CPU overhead
  • Near-native I/O performance
  • Balloon driver for memory
  • Guest-host communication

Advantages of KVM

Performance

Integration

Cost and Licensing

Supported Guest Operating Systems

KVM supports a wide variety of guest operating systems through full virtualization:

Compatible Guest OS

  • Linux: All major distributions (RHEL, CentOS, Ubuntu, Debian, SUSE, etc.)
  • Windows: Windows Server 2008-2022, Windows 7-11
  • BSD: FreeBSD, OpenBSD, NetBSD
  • Solaris: Oracle Solaris and OpenSolaris
  • Legacy Systems: MS-DOS, older Windows versions
  • Other Unix: AIX, HP-UX (limited support)

KVM Features

Live Migration

Move running VMs between physical hosts with minimal downtime:

Snapshots and Cloning

Resource Management

CPU and Memory Management

  • CPU Pinning: Bind VMs to specific CPU cores
  • CPU Shares: Proportional CPU allocation
  • CPU Limits: Maximum CPU quota enforcement
  • Memory Ballooning: Dynamic memory adjustment
  • Memory Overcommit: KSM (Kernel Samepage Merging)
  • NUMA Awareness: Optimal NUMA node placement

Storage Options

Disk Image Formats

Format Features Use Case
QCOW2 Snapshots, compression, encryption General purpose, development
RAW No overhead, best performance Production, databases
VDI VirtualBox compatibility Cross-platform migration
VMDK VMware compatibility VMware migrations
VHD/VHDX Hyper-V compatibility Microsoft environments

Storage Backends

Networking

Network Modes

NAT Mode

  • Default networking mode
  • VMs share host IP
  • Outbound connectivity
  • Port forwarding for inbound
  • Isolated from network

Bridge Mode

  • VMs on physical network
  • Direct network access
  • Own IP addresses
  • No port forwarding needed
  • Production standard

Host-Only

  • VMs communicate with host
  • Isolated from external network
  • Development/testing
  • Private VM network
  • Secure isolation

Macvtap

  • Direct physical NIC access
  • No bridge overhead
  • Better performance
  • SR-IOV support
  • VEPA mode available

Use Cases

Cloud Infrastructure

KVM powers major cloud platforms:

Server Virtualization

Development and Testing

Management Tools

virsh

  • Command-line interface
  • libvirt-based management
  • Scriptable operations
  • Remote management

virt-manager

  • GUI management tool
  • Easy VM creation
  • Graphical console access
  • Resource monitoring

Cockpit

  • Web-based management
  • Modern interface
  • Multi-host management
  • Integrated monitoring

Proxmox

  • Complete platform
  • Web GUI
  • Cluster management
  • Built-in backup

Security Features

Built-in Security

  • SELinux/AppArmor: Mandatory access control integration
  • sVirt: SELinux integration for VM isolation
  • Seccomp: System call filtering for QEMU
  • VM Isolation: Hardware-based memory isolation
  • Encrypted VMs: Full disk encryption support
  • Secure Boot: UEFI Secure Boot for guests
  • TPM: Virtual TPM support

Performance Optimizations

Enterprise Support

Commercial support and distributions:

Vendor Product Features
Red Hat RHEL with KVM Enterprise support, RHV for management
SUSE SLES with KVM Enterprise support, comprehensive tooling
Canonical Ubuntu with KVM LTS support, OpenStack integration
Oracle Oracle Linux KVM Oracle workload optimization

Comparison with Other Hypervisors

KVM vs. Alternatives

  • vs. VMware: Open-source, no licensing costs, kernel-integrated
  • vs. Xen: Better Linux integration, simpler architecture
  • vs. Hyper-V: Linux-native, better Linux guest support
  • vs. VirtualBox: Production-ready, better performance, enterprise features

Getting Started

System Requirements

Basic Installation

# Ubuntu/Debian
sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager

# RHEL/CentOS/Fedora
sudo dnf install qemu-kvm libvirt virt-install virt-manager

# Verify KVM modules are loaded
lsmod | grep kvm

# Check virtualization support
virt-host-validate

Community and Resources

Note: KVM continues to evolve with each Linux kernel release, adding new features and performance improvements. This guide provides an overview of KVM capabilities. Explore the Architecture, QEMU, Commands, and Management sections for detailed technical information.