2.6.1. Hypervisors and Virtual Machine Concepts
💡 First Principle: Linux uses a Type 1 hypervisor built into the kernel — KVM (Kernel-based Virtual Machine). Combined with QEMU for hardware emulation, KVM/QEMU provides full virtualization at near-native performance. The kernel's position as Type 1 hypervisor means no separate hypervisor OS is needed — Linux IS the hypervisor.
Key Virtualization Concepts:
VirtIO: Para-virtualized drivers that guest OSes use to communicate with virtual hardware more efficiently than emulated hardware. VirtIO network (virtio-net) and disk (virtio-blk, virtio-scsi) drivers provide significantly better performance than emulated e1000 NICs or IDE controllers.
Paravirtualization: The guest OS is modified to be "hypervisor-aware" — instead of emulating real hardware interactions, it makes hypercalls directly. VirtIO drivers are the practical implementation of this concept on Linux KVM systems.
Disk Image Formats:
| Format | Extension | Key Feature | Operations |
|---|---|---|---|
| qcow2 | .qcow2 | Copy-on-write, snapshots, compression | Default KVM format |
| raw | .img | Byte-for-byte copy, maximum performance | Best I/O performance |
# Disk image operations (qemu-img)
qemu-img create -f qcow2 vm.qcow2 50G # Create new 50 GB qcow2 image
qemu-img info vm.qcow2 # Image properties (format, size, backing file)
qemu-img convert -f raw -O qcow2 disk.img vm.qcow2 # Convert raw to qcow2
qemu-img resize vm.qcow2 +20G # Grow image by 20 GB
qemu-img snapshot -c snap1 vm.qcow2 # Create internal snapshot
VM States:
| State | Description |
|---|---|
| Running | VM is actively executing |
| Paused | Execution suspended; memory preserved |
| Shut off | VM is not running; disk state preserved |
| Saved | State written to disk (hibernation); can be restored |
| Crashed | VM terminated abnormally |
Nested Virtualization: Running a hypervisor inside a VM — a VM hosts its own VMs. Requires hardware support (vmx flag for Intel, svm for AMD) and enabling nested=1 in the KVM module. Common in lab environments and CI/CD systems.
⚠️ Exam Trap: QEMU alone does software emulation — slow. KVM alone provides kernel-level virtualization hooks — but needs QEMU to handle device I/O. Together, KVM+QEMU provides near-native performance. On the exam, "KVM" usually implies the KVM+QEMU combination. Check for hardware virtualization support with: grep -E 'vmx|svm' /proc/cpuinfo.
Reflection Question: A VM built on KVM/QEMU shows poor network throughput despite the physical host having a fast NIC. The VM uses an emulated Intel e1000 NIC. What change would significantly improve performance without changing the physical hardware?