All guides
Term

KVM

An open-source virtualization technology for Linux that turns the kernel into a type-1 hypervisor.

KVM (Kernel-based Virtual Machine) is an open-source virtualization technology built directly into Linux that turns the operating system kernel into a type-1 (bare-metal) hypervisor. By leveraging hardware virtualization extensions such as Intel VT-x or AMD-V, it allows a host machine to run multiple isolated virtual machines (VMs) running unmodified Linux, Windows, or BSD guest operating systems. Because each VM executes as a standard Linux process, administrators can rely on familiar kernel subsystems and management tools for scheduling, memory allocation, and resource control.

How it works

KVM converts the Linux kernel into a hypervisor by loading dedicated kernel modules (kvm.ko alongside processor-specific kvm-intel.ko or kvm-amd.ko). It relies on existing kernel components—such as the process scheduler, network stack, and memory management unit (MMU)—to handle low-level resource allocation, while delegating hardware emulation to user-space software.

  • Hardware access: KVM exposes the /dev/kvm character device, which user-space emulators like QEMU use to configure guest memory spaces, manage virtual CPUs, and emulate peripherals.
  • I/O optimization: Through virtio, a paravirtualization framework, guest operating systems use specialized drivers to communicate directly with the hypervisor, avoiding the overhead of emulating physical network cards and disk controllers.
  • Process-level control: Because every virtual machine runs as a standard host process, administrators can inspect, prioritize, or terminate instances using native utilities like top, kill, and cgroups.
  • Isolation and security: KVM integrates with SELinux and sVirt to enforce mandatory access control (MAC), ensuring strict boundaries between individual virtual machines and the underlying host.

Example

Before deploying workloads, verify that the host CPU supports hardware virtualization and that the KVM kernel modules are active, then launch a guest image using QEMU with KVM acceleration enabled:

# Verify CPU virtualization extensions and loaded modules
grep -E -c '(vmx|svm)' /proc/cpuinfo
lsmod | grep kvm

# Launch a VM with 2 vCPUs, 2 GB RAM, and virtio networking/storage
qemu-system-x86_64 \
  -enable-kvm \
  -cpu host \
  -m 2048 \
  -smp 2 \
  -drive file=/var/lib/libvirt/images/app-server.qcow2,if=virtio \
  -nic user,model=virtio-net-pci

In production environments, administrators typically manage these definitions declaratively through libvirt and command-line tools like virsh or automation platforms rather than invoking raw QEMU commands manually.

What matters when choosing a server or hosting

  • Dedicated resource allocation: In VPS and cloud hosting, KVM enforces strict RAM and storage boundaries compared to container-based virtualization, preventing neighboring tenants from consuming your allocated memory.
  • Nested virtualization support: If you plan to run Docker, Kubernetes test clusters, or secondary hypervisors inside a VM, confirm that your hosting provider exposes CPU virtualization flags to the guest.
  • Storage and network drivers: Ensure your host configuration and guest images use virtio-blk or virtio-scsi for disk I/O and virtio-net for networking to achieve near-native throughput.
  • CPU pinning and NUMA alignment: For latency-sensitive databases or compute-heavy workloads, look for dedicated vCPU plans that align guest memory and cores with the host's physical NUMA nodes.

Common mistakes

  • Running without /dev/kvm enabled: Launching QEMU when virtualization extensions are disabled in the server BIOS/UEFI causes silent fallback to pure software emulation, degrading performance drastically.
  • Using legacy emulated drivers: Configuring guests with IDE disks or emulated Intel e1000 network cards instead of virtio devices creates severe I/O bottlenecks under load.
  • Overcommitting memory without safeguards: While KVM supports memory ballooning and Kernel Same-page Merging (KSM), aggressive RAM overcommitment without swap or strict cgroup limits triggers the host out-of-memory (OOM) killer, abruptly terminating running VMs.

FAQ

Is KVM a type-1 or type-2 hypervisor?

KVM is a type-1 hypervisor. Although it runs inside a full Linux operating system, the KVM kernel module grants guest code direct access to the host CPU hardware, eliminating the translation layer typical of type-2 hypervisors.

What is the difference between KVM and QEMU?

KVM is the kernel module that handles CPU and memory virtualization via hardware extensions, whereas QEMU is a user-space emulator that provides virtual motherboards, storage controllers, and network interfaces. Together, QEMU uses KVM to run VMs at near-native speed.

Can KVM run Windows virtual machines?

Yes. Because KVM relies on hardware-assisted full virtualization, it runs unmodified Windows guests alongside Linux and BSD instances, provided you supply the Windows VirtIO drivers during installation for optimal disk and network speed.

All glossary terms

Glossary

Related terms

Full glossary

New guides every week.

A digest of the best pieces on servers, VPN and self-hosted software. No ads, no spam.

1 email a weekOne-click unsubscribeRU · EN
Only slipjar.app articles, nothing else.