Course: Cloud Computing Technologies
Professor: Fulvio Risso, Politecnico di Torino
Source deck: Computing Virtualization in Linux, 05 - Computing virtualization in Linux.pdf, 36 PDF pages.
Documentation date: 30 October 2026. Lecture date: not stated. 05 follows the source filename.

Source and scope

These notes organize the explanations supplied in the shared teaching conversation, as requested. They are not a fresh slide-by-slide transcription of the PDF. Original PDF viewer.

Slide references below are the printed slide numbers reported in that conversation, not PDF page numbers. The deck has 36 PDF pages with gaps in printed numbering. No unverified slide-to-page conversion is implied. Analogies, packet paths, worked examples and technical qualifications are added study explanations from the conversation. Commands are illustrative and were not executed.

Shared mechanisms retain their existing concept homes under Lecture 03. The new networking and Vagrant concepts introduced in this documentation live under 20 Concepts/Cloud Computing Technologies/Lecture 05 - Computing Virtualization in Linux/. This keeps the source lesson identifiable while avoiding duplicate QEMU/KVM or Virtio notes.

Lecture summary

A guest OS expects a whole computer, not just permission to execute instructions. QEMU supplies the machine environment and devices; KVM supplies Linux-kernel support for hardware-assisted guest execution. With compatible architectures, most guest CPU code can execute directly under hardware controls. Cross-architecture execution needs translation instead. QEMU and KVM

Linux already manages processes, memory, devices and CPU scheduling. The QEMU/KVM design reuses those services: one QEMU process normally represents a VM, guest RAM has host backing, and vCPUs execute through host threads. The guest scheduler selects work for its vCPUs; the host scheduler selects when their threads run. QEMU and KVM

To manage these machines, libvirt supplies an API, virsh a command-line client, and virt-manager a graphical client. Their configuration and lifecycle path is separate from the execution path of every guest instruction. A domain XML describes virtual hardware and storage references, not the installed operating system itself. Libvirt virsh and virt-manager

A virtual NIC also needs connectivity. Bridges connect interfaces at Ethernet level; routing forwards between IP networks; NAT additionally translates addresses. NAT, routed, bridged and isolated networks have different return-path and reachability requirements. Linux VM Networking - NAT Routed Bridged and Isolated

Once a setup is described rather than assembled manually, it can be recreated. Vagrant records a development environment in a Vagrantfile, using a provider to create machines and a provisioner to configure their software. Vagrant Boxes Providers and Provisioning

CPU acceleration does not eliminate device overhead. Virtio gives guest drivers and backends an interface designed for virtualization. Virtqueues describe buffers and completion, scatter-gather represents data in separate regions, and vhost-net moves frequent network processing into the kernel. Notifications tell the other side about work without carrying the packet itself. Virtio Virtqueues and vhost-net

Explanation map

Printed slides reported in the conversationTopicReusable note
3-9QEMU modes, KVM, Linux reuse, VM process, RAM, demonstration flagsQEMU and KVM
11-12Main/event loop, vCPU threads, worker/I/O threadsQEMU and KVM
14-18/dev/kvm, lifecycle, exits, rings and VMX modesQEMU and KVM, Hardware-Assisted Virtualization and VMCS
20-24libvirt, virsh, virt-manager and XMLLibvirt virsh and virt-manager
25-27NAT, routed, bridged and isolated networksLinux VM Networking - NAT Routed Bridged and Isolated
28-29Vagrant and reproducible environmentsVagrant Boxes Providers and Provisioning
30-33Virtio, frontend/backend, queues and scatter-gatherVirtio Virtqueues and vhost-net
34-37vhost-net, TAP and control/data responsibilitiesVirtio Virtqueues and vhost-net
38-39eventfd, ioeventfd and irqfdVirtio Virtqueues and vhost-net

1. QEMU models the computer; KVM accelerates execution

QEMU can provide a virtual CPU, RAM, firmware, disk controller, network card and display. In software CPU emulation it translates blocks of guest instructions into code the host can execute, caching translated blocks for reuse.

Mode or setupWhat it doesIllustrative example
User-mode emulationRuns one foreign-architecture program and adapts OS interactionsARM Linux executable on x86 Linux; no guest kernel is booted
System emulationProvides a complete machine, including a guest OSARM Linux system on an x86 host
System virtualization with KVMUses hardware assistance for compatible guest CPU executionx86 guest on a compatible x86 host

KVM does not make an x86 processor directly understand ARM instructions. On the x86 setup discussed, kvm.ko supplies common infrastructure and kvm-intel.ko / kvm-amd.ko provide processor-specific support. A loadable kernel module adds functionality to the running kernel.

Direct execution remains controlled execution: Linux/KVM retains authority over physical resources. The lecture uses Intel VT-x and AMD-V as the relevant processor extensions. Its guest-unawareness claim means unmodified operating systems can run; it does not mean virtualization is undetectable or that cooperative device drivers are forbidden.

2. A VM is represented by host processes and threads

Added example from the conversation: configure a VM with 4 GB RAM, two vCPUs, a virtual disk and a virtual NIC. The host normally has a QEMU process with guest-memory mappings and several threads. Each vCPU has an associated host execution thread; main-loop and I/O workers handle other responsibilities.

There are two scheduling decisions:

  1. The guest OS schedules its application threads onto the guest vCPUs.
  2. Linux schedules the host vCPU threads onto real processors.

A guest with 100 application threads and two vCPUs does not thereby create 100 corresponding host scheduler threads. Likewise, four vCPUs do not automatically reserve four physical cores; dedicated placement needs explicit configuration.

Guest RAM is backed by host-managed memory, typically mapped into the QEMU process. Distinguish guest virtual, guest physical, host virtual and host physical addresses. Host virtual mappings describe how QEMU accesses backing memory; they are not an extra software translation step that every native guest CPU load must traverse. Hardware translations ultimately reach machine memory. See Memory Virtualization - Shadow Page Tables and EPT.

SeaBIOS in the lesson diagram provides virtual-machine firmware startup. Other virtual-machine configurations can use UEFI firmware instead.

3. How QEMU asks KVM to execute a guest

/dev/kvm is a kernel interface exposed through a device path. Opening it yields a file descriptor: an integer handle referring to a kernel object. Separate VM and vCPU objects have their own handles. An ioctl is a system call for interface-specific operations.

Conceptual stepPurpose
Open /dev/kvmObtain access to KVM
KVM_CREATE_VMCreate a VM object
Allocate/map guest backingProvide RAM
KVM_SET_USER_MEMORY_REGIONRegister the GPA-to-host-userspace memory relationship
KVM_CREATE_VCPUCreate a virtual CPU
Map kvm_run and initialize stateShare run/exit information and prepare execution
KVM_RUNBegin or resume execution of the vCPU

For an operation needing userspace emulation:

QEMU vCPU thread -> KVM_RUN -> KVM -> VM entry -> guest
guest operation -> VM exit -> KVM -> return to QEMU if needed
QEMU handles the operation -> KVM_RUN -> resume

KVM can handle some exits internally and resume without returning to QEMU. A VM exit is not necessarily an error. Many guest exceptions can be handled by the guest itself without a VM exit.

Rings and modes are separate

Code in the simplified Intel modelRingVMX mode
QEMU host process3Root
Host kernel / KVM0Root
Guest kernel0Non-root
Guest application3Non-root

VMX root mode is not the Linux root account. QEMU remains a userspace process, and guest ring 0 remains subordinate to host virtualization controls.

Treat the sample code as a sketch

The shared explanation identifies these issues in printed slide 14’s example: asking mmap() for 0x1000 bytes specifies a length, not a mapping at address 0x1000; x86 RIP belongs to KVM_SET_REGS, not the special-register structure used by KVM_SET_SREGS; guest memory registration needs a populated region structure. These are supplied study corrections, not a tested replacement program. The existing QEMU and KVM note links the Linux KVM API supporting the register distinction.

4. Read the demonstrations for their mechanism

The lesson compares the following illustrative commands:

qemu-system-x86_64 -nographic disk.img
qemu-system-x86_64 -nographic -enable-kvm disk.img

The intended comparison is translated CPU execution versus hardware assistance, rather than a promised speed ratio. Old image downloads and machine settings are historical demonstration context.

FlagMeaning in the examples
-smp 2Present two vCPUs
-m 1024Configure 1024 MiB guest RAM
-M virtSelect the generic ARM virtual-machine model in that demonstration
-bios ...Supply firmware
-nographicUse terminal-based output instead of a graphical display
-drive ...Define storage backing
-device ...Attach a guest-visible device

The separation of -drive and -device distinguishes where data lives from the interface the guest uses to reach it.

5. Management, networking and reproducible setup

Libvirt manages VM creation, configuration, monitoring and lifecycle across supported backends. In this context a domain means a managed VM, not an Internet domain. virsh provides command-line access and virt-manager provides graphical management and guest-console access. The viewer displays the VM; it does not execute guest CPU instructions.

The example XML contains 1048576 KiB and one vCPU: that memory is 1 GiB. The XML describes configuration and references storage; the guest OS installation normally lives in the disk image or device.

For network access, identify the guest’s address, the host’s forwarding role and the return path. NAT commonly allows outgoing connections from a private guest subnet without requiring outside routers to know that subnet. Routed mode preserves the guest address and requires a suitable return route. Bridged guests generally join the physical LAN, while isolated networks have no configured forwarding path outside. DHCP assigns configuration; DNS resolves names; dnsmasq can provide both. See Linux VM Networking - NAT Routed Bridged and Isolated.

Vagrant turns a reproducible development setup into a Vagrantfile. A box supplies a packaged base environment, a provider supplies the execution backend, and a provisioner configures software. See Vagrant Boxes Providers and Provisioning.

6. Virtio: efficient cooperation for devices

Hardware-assisted CPU execution can coexist with paravirtualized I/O. A Virtio guest frontend communicates with a host backend through a device interface designed for VMs, rather than imitating every behavior of a particular physical card. Examples include virtio-net and virtio-blk. Ballooning is a separate cooperative memory-management use; it does not perform EPT translation.

A virtqueue describes buffers and their availability/completion. For TX, the guest offers outgoing buffers, the backend processes them and reports completion before buffers are reused. For RX, the guest first supplies empty writable buffers, then the backend fills them and reports completion.

The basic network model has TX/RX queues and an optional control queue; configurations may have multiple queue pairs. Scatter-gather describes logically connected data in separate memory regions through addresses and lengths. The writev() example illustrates one operation over several buffers; it is not itself a Virtio implementation and does not guarantee zero copying.

7. vhost-net and the notification doorbells

QEMU backend: guest Virtio -> QEMU userspace -> host networking / TAP
vhost-net:    guest Virtio -> kernel vhost-net -> host networking / TAP

TAP is a host virtual Ethernet interface that can connect a VM backend to a bridge or other networking facilities. vhost-net moves frequent packet processing into the host kernel. QEMU still performs setup and control, including device configuration and feature negotiation. The guest keeps the same Virtio interface.

Queues identify work, but another mechanism signals that work exists. An eventfd is a kernel event-notification object, accessed through a file descriptor. It is a doorbell, not a packet transport.

MechanismDirectionMeaning
ioeventfdGuest notification toward backendA guest I/O notification signals available work
irqfdBackend notification toward guestAn eventfd can trigger injection of a virtual interrupt

For TX, the guest posts descriptors and kicks the backend; KVM can route the relevant I/O notification to an eventfd without QEMU handling the kick in userspace. For RX, the backend fills guest buffers and updates completion; when notification is needed, irqfd supports the interrupt path. Neither mechanism carries packet bytes or eliminates every transition cost.

8. Follow one browser request end to end

Added integrated example from the shared lesson:

  1. Virt-manager submits a VM configuration through libvirt.
  2. Libvirt launches/configures QEMU, which creates VM/vCPU objects through KVM.
  3. Linux schedules the vCPU threads; inside the guest, its OS schedules the browser.
  4. The browser’s request traverses the guest networking stack.
  5. The Virtio frontend posts TX buffer descriptors and notifies the backend.
  6. With vhost-net, the kernel backend processes data and reaches host networking through the configured TAP path.
  7. The selected bridge/routing/NAT arrangement and physical interface deliver external traffic.
  8. Replies reach the backend, which fills guest-provided RX buffers and reports completion.
  9. A virtual interrupt can notify the guest, whose stack delivers the reply to the browser.

The management tools are not in the path of every packet. QEMU remains responsible for the VM even when frequent guest execution and packet processing avoid userspace handling.

Source qualifications

  • Guest compatibility is not a claim that virtualization cannot be detected.
  • Exceptions, VM exits and returns to QEMU are distinct events.
  • Guest physical and host physical addresses are not interchangeable; QEMU’s host virtual mapping does not add a software hop to every CPU load.
  • The source’s Virtio speed ratios are workload/configuration examples, not universal guarantees.
  • “No system calls” in the vhost discussion refers to avoiding repeated QEMU packet handling, not the absence of setup or management syscalls.
  • Hypervisor coexistence, production suitability, old downloads and device IDs are source-era context, not verified advice for a current installation.

Revision questions and answer guide

Try explaining the mechanism before consulting the answer.

QuestionEssential reasoning
Why QEMU if KVM exists?CPU execution is only part of a VM; machine/device models and userspace lifecycle services remain necessary.
Do four vCPUs reserve four cores?No: vCPU threads are scheduled unless resource placement/dedication is explicitly configured.
Can KVM directly run ARM instructions on x86?No: hardware assistance does not translate an incompatible ISA.
Why is guest ring 0 still controlled?It operates in guest/non-root mode under host virtualization controls.
Does every VM exit reach QEMU?No: KVM can handle some internally; others need userspace services.
Why must a routed guest have a return route?Outbound forwarding alone does not tell outside routers how to reach the guest subnet.
How do Virtio and vhost-net differ?Virtio defines guest/backend cooperation; vhost-net implements the frequent network data path in the kernel.
What carries data and what signals activity?Memory buffers hold data, queues describe work and completion, eventfd-based paths signal notifications.
What do box/provider/provisioner mean?Base environment, machine backend and in-guest software configuration respectively.