What is the difference between emulation and virtualization (QEMU TCG vs KVM)?
Short answer: Emulation runs guest instructions by translating them in software, so the guest CPU can be a different architecture from the host (ARM guest on an x86 PC). QEMU does this with TCG. Hardware-assisted virtualization runs guest instructions directly on the real CPU, with hardware support to trap the few operations the hypervisor must control; guest and host must be the same architecture. KVM is the Linux kernel part that provides this, and QEMU uses it as an accelerator.
| QEMU with TCG (emulation) | QEMU + KVM (virtualization) | |
|---|---|---|
| Guest instructions | translated to host code by software | run natively on the CPU |
| Guest arch | any QEMU supports (ARM on x86, RISC-V on ARM) | same as host (ARM64 on ARM64, x86 on x86) |
| Speed | roughly 5–20× slower than native, depends heavily on workload | close to native for CPU work |
| Needs | nothing special | CPU virtualization extensions (ARM EL2, Intel VT-x, AMD-V) and /dev/kvm |
| Device models | QEMU (user space) | still mostly QEMU, plus in-kernel GIC/timer and vhost |
| Typical use | pre-silicon bring-up, cross-arch development, CI, debugging | servers, cloud, automotive/industrial consolidation |
Who does what with KVM
- KVM (kernel module / built-in): creates VMs and vCPUs, sets up stage-2 page tables, switches the CPU between host and guest, handles most traps itself (system registers, timers, interrupt controller).
- QEMU (user space): parses the command line, builds the machine (memory map, device tree, devices), loads the kernel, runs one thread per vCPU calling
ioctl(KVM_RUN), and emulates devices when the guest touches their MMIO space.
Other user-space VMMs using KVM: Firecracker, Cloud Hypervisor, crosvm, kvmtool (lkvm). They are smaller than QEMU and support fewer devices.
One-line summary for interviews: "QEMU is the machine emulator and VMM; TCG is how it runs foreign code; KVM is how it runs native code at near-native speed using the CPU's virtualization extensions."