Component Principles
KVM
KVM uses features of the Linux kernel to implement functions such as CPU virtualization, memory virtualization, peripheral virtualization, and VM management. It is a bridge for software to simulate hardware and mode conversion. Figure 1 shows the KVM architecture.
KVM is a hypervisor that runs in the host OS kernel. It simulates the CPU, memory, and I/O, monitors VMs, and provides entity support for the QEMU.
KVM has the following advantages:
- High compatibility
- Easy memory management. A VM is a process.
- High performance. The code resources of the KVM and OS kernel can be directly invoked.
- Focus on virtualization. Hardware is fully utilized to support virtualization.
- Good scalability. Memory management and multi-processor functions provided by the Linux kernel can be directly used.
- Simplicity. Currently, KVM I/O virtualization is implemented by using QEMU, which significantly reduces the implementation workload.
QEMU
QEMU is an emulator that provides a hardware environment for running VMs. It runs in the user mode on the host as a process. Based on the KVM and kernel features, QEMU simulates hardware such as the CPUs, memory, and I/O devices to support running of the guest OS in a process. QEMU supports full system emulation, full virtualization, and paravirtualization. Full system simulation and full virtualization are pure software simulation. A process constructed by a CPU can run on another CPU. The difference is that full system simulation allows the entire system to be simulated, including CPUs and peripheral devices, whereas in paravirtualization mode, QEMU and KVM are used together to simulate the CPU in KVM hardware-assisted virtualization mode. The paravirtualization mode is efficient and is commonly used. Figure 2 shows the QEMU architecture.
QEMU works with KVM. KVM runs in
- QMP interfaces for interaction with the upper-layer libvirt
- Virtual devices simulation
- ioctl interface for interaction with the lower-layer KVM

