Book Image

Mastering KVM Virtualization - Second Edition

By : Vedran Dakic, Humble Devassy Chirammal, Prasad Mukhedkar, Anil Vettathu
5 (1)
Book Image

Mastering KVM Virtualization - Second Edition

5 (1)
By: Vedran Dakic, Humble Devassy Chirammal, Prasad Mukhedkar, Anil Vettathu

Overview of this book

Kernel-based Virtual Machine (KVM) enables you to virtualize your data center by transforming your Linux operating system into a powerful hypervisor that allows you to manage multiple operating systems with minimal fuss. With this book, you'll gain insights into configuring, troubleshooting, and fixing bugs in KVM virtualization and related software. This second edition of Mastering KVM Virtualization is updated to cover the latest developments in the core KVM components - libvirt and QEMU. Starting with the basics of Linux virtualization, you'll explore VM lifecycle management and migration techniques. You’ll then learn how to use SPICE and VNC protocols while creating VMs and discover best practices for using snapshots. As you progress, you'll integrate third-party tools with Ansible for automation and orchestration. You’ll also learn to scale out and monitor your environments, and will cover oVirt, OpenStack, Eucalyptus, AWS, and ELK stack. Throughout the book, you’ll find out more about tools such as Cloud-Init and Cloudbase-Init. Finally, you'll be taken through the performance tuning and troubleshooting guidelines for KVM-based virtual machines and a hypervisor. By the end of this book, you'll be well-versed with KVM virtualization and the tools and technologies needed to build and manage diverse virtualization environments.
Table of Contents (22 chapters)
1
Section 1: KVM Virtualization Basics
4
Section 2: libvirt and ovirt for Virtual Machine Management
11
Section 3: Automation, Customization, and Orchestration for KVM VMs
15
Section 4: Scalability, Monitoring, Performance Tuning, and Troubleshooting

Open source virtualization projects

The following table is a list of open source virtualization projects in Linux:

Figure 1.3 – Open source virtualization projects in Linux

Figure 1.3 – Open source virtualization projects in Linux

In the upcoming sections, we will discuss Xen and KVM, which are the leading open source virtualization solutions in Linux.

Xen

Xen originated at the University of Cambridge as a research project. The first public release of Xen was in 2003. Later, the leader of this project at the University of Cambridge, Ian Pratt, co-founded a company called XenSource with Simon Crosby (also from the University of Cambridge). This company started to develop the project in an open source fashion. On 15 April 2013, the Xen project was moved to the Linux Foundation as a collaborative project. The Linux Foundation launched a new trademark for the Xen Project to differentiate the project from any commercial use of the older Xen trademark. More details about this can be found at https://xenproject.org/.

The Xen hypervisor has been ported to a number of processor families, such as Intel IA-32/64, x86_64, PowerPC, ARM, MIPS, and so on.

The core concept of Xen has four main building blocks:

  • Xen hypervisor: The integral part of Xen that handles intercommunication between the physical hardware and virtual machine(s). It handles all interrupts, times, CPU and memory requests, and hardware interaction.
  • Dom0: Xen's control domain, which controls a virtual machine's environment. The main part of it is called QEMU, a piece of software that emulates a regular computer system by doing binary translation to emulate a CPU.
  • Management utilities: Command-line utilities and GUI utilities that we use to manage the overall Xen environment.
  • Virtual machines (unprivileged domains, DomU): Guests that we're running on Xen.

As shown in the following diagram, Dom0 is a completely separate entity that controls the other virtual machines, while all the other are happily stacked next to each other using system resources provided by the hypervisor:

Figure 1.4 – Xen

Figure 1.4 – Xen

Some management tools that we're going to mention a bit later in this book are actually capable of working with Xen virtual machines as well. For example, the virsh command can be easily used to connect to and manage Xen hosts. On the other hand, oVirt was designed around KVM virtualization and that would definitely not be the preferred solution to manage your Xen-based environment.

KVM

KVM represents the latest generation of open source virtualization. The goal of the project was to create a modern hypervisor that builds on the experience of previous generations of technologies and leverages the modern hardware available today (VT-x, AMD-V, and so on).

KVM simply turns the Linux kernel into a hypervisor when you install the KVM kernel module. However, as the standard Linux kernel is the hypervisor, it benefits from the changes that were made to the standard kernel (memory support, scheduler, and so on). Optimizations for these Linux components, such as the scheduler in the 3.1 kernel, improvement to nested virtualization in 4.20+ kernels, new features for mitigation of Spectre attacks, support for AMD Secure Encrypted Virtualization, Intel iGPU passthrough in 4/5.x kernels, and so on benefit both the hypervisor (the host OS) and the Linux guest OSes. For I/O emulations, KVM uses a userland software, QEMU; this is a userland program that does hardware emulation.

QEMU emulates the processor and a long list of peripheral devices such as the disk, network, VGA, PCI, USB, serial/parallel ports, and so on to build a complete piece of virtual hardware that the guest OS can be installed on. This emulation is powered by KVM.