Roles

ComponentRole in the lecture’s Linux stack
QEMUUserspace VM setup, machine/device models, lifecycle and migration support
KVMLinux kernel virtualization interface and hardware-assisted guest execution
Linux kernelHost scheduling, memory management, drivers, and supporting infrastructure
Guest OSKernel and applications running inside the virtual machine

QEMU can also emulate a whole system across different ISAs. Its user-mode emulation runs an individual foreign-ISA program; system mode supplies a complete machine. KVM acceleration in the lecture requires a compatible host/guest ISA and virtualization hardware.

VM process and vCPU threads

The illustrated VM is backed by a QEMU process. Guest RAM belongs to that process’s address space; each guest vCPU executes through a host thread. A main loop handles events and other threads can perform expensive I/O.

The host scheduler sees host threads, not every guest application thread as a separate schedulable host entity. The guest OS schedules its own work onto its vCPUs.

Lifecycle through /dev/kvm

The slide’s conceptual flow is:

  1. Open /dev/kvm.
  2. Create a VM and register guest-memory backing.
  3. Create vCPUs and map their kvm_run communication structures.
  4. Initialize processor state.
  5. Call KVM_RUN to execute.
  6. Handle returned exit reasons where userspace emulation is needed, then resume.
QEMU (root ring 3) -> host syscall -> KVM (root ring 0)
KVM -> VM entry -> guest (non-root kernel/apps)
Guest -> VM exit -> KVM -> handle in kernel or return to QEMU

Not every VM exit makes a userspace round trip.

Correction to the schematic code

PDF page 80 / printed slide 85 is not a complete executable example. In the x86 API, KVM_SET_REGS sets general registers including RIP, while KVM_SET_SREGS sets special registers. The slide mixes these categories. Linux KVM API.

Lecture demonstrations

Pages 76-77 compare x64 emulation with -enable-kvm and an ARM64 guest emulated on x86. The supplied Ubuntu 20.04/21.04 downloads and firmware commands are recorded as historical demonstrations, not tested setup instructions. No VM was launched for these notes.

Lecture 05 study extensions

The separate Lecture 05 - Computing Virtualization in Linux explanation develops the same stack. Its printed-slide references are not Lecture 03 PDF page references.

Two schedulers, different threads

A VM with two vCPUs and 100 guest application threads normally has two host vCPU execution threads, alongside QEMU’s event/I/O workers. The guest schedules applications onto vCPUs; the host schedules vCPU threads onto physical CPUs. Assigning four vCPUs does not automatically reserve four cores.

Memory backing and firmware

Guest RAM is typically mapped into the QEMU process. Guest virtual, guest physical, host virtual and host physical addresses describe different views. QEMU’s host virtual mapping lets the host process reach the backing; it is not an extra software hop on every native guest CPU load. SeaBIOS in the lesson provides firmware startup; UEFI is another firmware option.

Read the API sketch carefully

The shared explanation for printed slide 14 adds two qualifications: mmap() length 0x1000 requests 4096 bytes rather than placement at address 0x1000, and KVM_SET_USER_MEMORY_REGION needs an actual populated region structure. The general/special register correction above still applies. A file descriptor identifies an open kernel object; ioctl() requests an operation on that interface. kvm_run carries communication such as userspace exit reasons.

A guest exception can remain inside the guest; a hardware VM exit can be handled inside KVM; only a subset need a return to QEMU. These events should not be collapsed into one category.

Source: the Lecture 05 shared teaching explanation for printed slides 3-18. Its examples are explanatory, not executed programs. For detailed guest networking and environment automation, follow Linux VM Networking - NAT Routed Bridged and Isolated and Vagrant Boxes Providers and Provisioning.

Common mistakes

  • Assuming KVM replaces all QEMU responsibilities.
  • Assuming hardware acceleration translates arbitrary foreign ISAs.
  • Assuming a guest’s ten application threads become ten host threads.
  • Copying the schematic API example as working C.

Related: Hypervisor Architectures, Hardware-Assisted Virtualization and VMCS, Libvirt virsh and virt-manager, Virtio Virtqueues and vhost-net.

Source

Lecture 03 PDF pages 71-83 (printed slides 74-88, with gaps). Context: Lecture 03 - Computing Virtualization Technologies and Tools. The diagram and cautionary distinctions are study explanations; the API correction is separately sourced above.

From VM processes to isolated host processes

Linux Process Isolation and Container Assembly explains a different use of Linux process infrastructure: container applications share the host kernel while namespaces and cgroups separate environment and consumption. QEMU/KVM runs guest code with a guest kernel; a QEMU host process is not evidence that a VM and container have the same kernel boundary.