Week 2

Virtual Machines (VMs)

OPS3 - Virtualization and Cloud Infrastructure

Welcome to Week 2!

What You'll Learn This Week

1. Deep Dive: Linux Virtualization (KVM & QEMU)

1.1 The Engine: KVM (Kernel-based Virtual Machine)

Figure 1.2: The Cycle of Direct Execution and Trapped Emulation.

Code Snippet: Creating a VM via KVM API (C)

Figure 1.1: Simplified C code showing how a user-space program instructs the kernel to create a VM.

1.2 Advanced KVM Technologies

Modern KVM deployments leverage several advanced kernel features to maximize efficiency:

1.3 Practical: Verifying KVM Support

Before creating virtual machines, it is imperative to verify that the host system is correctly configured to support hardware-assisted virtualization. This involves checking the CPU capabilities, kernel module status, and user permissions.

If this command returns no output, it indicates that hardware virtualization is disabled at the firmware level. You must reboot the machine, enter the BIOS setup, and enable "Virtualization Technology" (often labeled as VT-x, Vanderpool, or SVM).

Once hardware support is confirmed, we must ensure the Linux kernel has loaded the KVM modules. The KVM system consists of a core module (kvm.ko) and a processor-specific module (kvm_intel.ko or kvm_amd.ko). We use lsmod to list loaded modules:

If these modules are not present, they can often be loaded manually using modprobe kvm_intel (or amd), provided the hardware support is active.

If you encounter a "Permission Denied" error when running QEMU, verify your group membership using the groups command. If the kvm group is missing, you must add your user to it (sudo usermod -aG kvm $USER) and log out/in to apply the changes.

You may encounter specific error messages during this verification process.

1.4 The Hardware: QEMU (Quick Emulator)

While KVM enables the kernel to execute instructions, it does not provide the "Computer." It is the role of QEMU to provide the motherboard, the chipset, the PCI bus, and the plugged-in devices. Without QEMU, KVM is just a fast calculator; with QEMU, it becomes a server.

When you configure a VM in Proxmox, you are actually selecting arguments for the QEMU binary, starting with the Machine Type.

QEMU allows granular control over how the CPU is presented to the guest OS. This is critical for licensing (some software is licensed per-socket) and performance (aligning with physical NUMA nodes).

This argument creates a topology of 1 Socket with 4 Cores. The Guest OS sees this exactly as if it were physical silicon.

In QEMU, every device is composed of two parts: the Frontend (what the Guest OS sees) and the Backend (how the Host handles the data).

1.5 Optimization: VirtIO (Paravirtualization)

Emulating physical hardware (like an Intel E1000 network card) is "expensive" because every packet sent requires a context switch (VM Exit) to write to device registers, which QEMU then has to decode and simulate.

Note: This is why you must select "VirtIO" for Network and Disk in Proxmox when performance matters.

1.6 Essential Command Reference

Section 1 Checkpoint

Summary:

Reflection:

Resources:

2. The Platform: Proxmox VE

2.1 Architectural Breakdown

Figure 2.1: Proxmox VE Architecture - Decoupling the Web Interface, API, and Core KVM Engine.

As illustrated in Figure 2.1, Proxmox VE is designed as a layered interaction model. It is not a monolithic black box, but a collection of distinct services working in harmony.

2.2 Key Components

Figure 2.2: The Proxmox VE Web Interface (GUI) providing a centralized view of the datacenter.

Section 2 Checkpoint

Summary:

Reflection:

3. VM Management Features

3.1 Cloning

Cloning is the process of creating a new virtual machine based on the state of an existing one. Proxmox offers two distinct methods suited for different use cases.

Figure 3.1: Full Clones copy data; Linked Clones reference data.

3.2 Snapshots

A snapshot preserves the state of a virtual machine at a specific point in time. Unlike a backup, which is a copy of data, a snapshot is a freeze-frame of the disk and memory state.

Snapshots are primarily used as a safety net before performing risky operations, such as major OS upgrades or testing unstable software. If the operation fails, the administrator can perform a "Rollback" to revert the system state exactly to the moment the snapshot was taken.

3.3 Console Access

Accessing the VM's display is handled via remote desktop protocols integrated into the browser.

NoVNC is the default HTML5-based console. It requires no plugins and renders the VM's display directly in any modern web browser using WebSockets. It is lightweight and universally compatible but has limited support for clipboard integration and audio forwarding.

Section 3 Checkpoint

Summary:

Reflection:

Resources:

4. Summary and Next Steps

Preparing for Week 3

Next week, we go deeper into the infrastructure. We will explore Virtual Networking Fundamentals. Since you now know that a VM is just a process, it's time to understand how to wire these processes together using Linux Bridges, veth pairs, and VLANs.

Checklist:

5. Lab Exercises

Summary

Review the key concepts covered in this week's material

Questions?