LPIC-3 Virtualization and Containerization study materials
LPIC-3 Virtualization and Containerization study resources

LPIC-3 Virtualization and Containerization: Virtualization

LPIC-3 Virtualization and Containerization · Work through your exam, one topic at a time.

All guide sections

Virtualization

Exam 306 separates virtualization from containerization because a hypervisor runs a full guest kernel on emulated or paravirtualized hardware, while containers share the host kernel. This domain tests how KVM, QEMU and libvirt divide the work, and how you define, boot, network and store virtual machines from the shell.

The stack

  • KVM is the in-kernel hypervisor exposed as /dev/kvm: it virtualizes CPU and memory but emulates no devices.
  • QEMU is the userspace device model (chipset, disk controllers, NICs). -accel kvm is what makes it near-native; without it QEMU interprets instructions.
  • libvirt is the management layer. libvirtd, or the newer modular virtqemud, exposes an API used by virsh, virt-install and virt-manager. Domains are XML documents, edited with virsh edit.

Storage and networking

  • qemu-img create -f qcow2 d.qcow2 20G makes a sparse image: qemu-img info reports 20 GiB virtual size but a small disk size that grows on write. Raw images are fully allocated and cannot hold internal snapshots.
  • The default network is NAT on virbr0 (192.168.122.0/24) served by dnsmasq: guests reach out, the LAN cannot reach in without forwarding.
  • Bridged guests need a host bridge declared as <interface type='bridge'>. macvtap is the bridge-free option, but its bridge mode blocks host-to-guest traffic.
  • virsh domifaddr reads from the qemu-guest-agent; with no agent channel defined it returns nothing even on a healthy guest.

Worked example

Grow a running VM disk by 10 GiB. virsh domblklist web01 shows vda mapped to web01.qcow2. Run qemu-img resize web01.qcow2 +10G: qcow2 supports growing virtual size online. The guest sees a larger block device, but the partition table and filesystem above it are unchanged, so run growpart /dev/vda 1 then resize2fs /dev/vda1. The reasoning is layered: qemu-img edits the image only. Shrinking reverses the order, and --shrink refuses below the highest allocated cluster anyway.

Traps that cost marks

  • virsh destroy is a hard power-off, not a delete. Remove a domain with virsh undefine; add --remove-all-storage to drop volumes too.
  • Hand-editing /etc/libvirt/qemu/*.xml skips schema validation and libvirt may overwrite it; use virsh edit.
  • The default NAT network is not autostarted everywhere: virsh net-autostart default.
  • Live virsh setmem needs the virtio-balloon driver in the guest.