Linux-KVM (Kernel-based Virtual Machine) Explained


In this article, we will go through the KVM (Kernel-based Virtual Machine) API. KVM is a Linux kernel subsystem that can be used to start a virtual machine that uses hardware virtualization technologies such as VT-x of Intel or AMD-V. Hardware virtualization technologies give way better performance than a full emulation of a virtual machine.


KVM is an event-driven module; as is the case for most of the Linux kernel subsystems. The events are triggered by the user-space (QEMU) through a well-defined API (Application Programming Interface). This API has no system call for itself and relies heavily on the ioctl (input/output control) system call.

Putting it all together

Steps executed to start a VCPU in guest mode

Examples from QEMU

Together we will explore the source code of QEMU to find the calls to the KVM API. Please find th used source code at: will be using mostly a grep on the source code. To find the location of the creation of the kvm_fd we use:


That was a brief description of the KVM API. Feel free to take a look at the Linux-kernel documentation for a more in-depth description of the API (



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store



Big fan of technology with a recent interest in finance following the rise of cryptocurrencies.