Welcome to the first chapter of Foundations of Libvirt Development. In this chapter, you’ll learn what this book covers and the conventions I use throughout.
What This Book Covers
This book is about the libvirt APIs and how to work with it to control virtual machines under the QEMU/KVM system. libvirt has APIs that support many languages, but this work concentrates on the Python language exclusively.
libvirt can be used to support a number of virtual machine types, and the APIs are a common entry point to any type of virtual machine. The virtual machines that are supported include (but are not limited to) KVM, QEMU, Xen, Virtuozzo, VMware ESX, LXC, bhyve, and more. All of these can be controlled programmatically via the libvirt APIs. The libvirt APIs works the same way across all the supported platforms.
This book does not cover how to install QEMU/KVM on any platform. It is assumed that you either have that knowledge already or are working on a system where it is already installed. See the documentation for your operating system for instructions on how to install virtual machine support.
The libvirt Python API is an object-oriented system. It provides classes for virtual connections, virtual machine (domain) interactions, virtual and real network support, storage support, and information retrieval from the main host system. All interaction with the system is through the supported classes, and thus you will need to understand object orientation under Python. Be sure you have this knowledge before attempting to use the Python libvirt API.
In addition to the API topics mentioned, the book covers general interactions such as creating/destroying entities like domains, networks, storage, and others. The book also covers topics such as obtaining information about objects, getting statistics about objects, changing the configuration of an object, starting/stopping an object, and adding/removing hardware from objects.
The libvirt API covers the entire life cycle of virtual objects, from creation to destruction. It contains everything needed to manage a virtual object during that life cycle. However, it doesn’t contain APIs for managing the object from inside (i.e., there are no APIs that connect to the object’s internal APIs). Thus, for domains (virtual machines), there is no way to submit jobs to the domain or monitor anything going on in the domain. That type of administration is left up to the administrator.
Book Conventions
This book uses several conventions to draw attention to specific pieces of information. The convention used depends on the type of information displayed.
Computer Commands
Run the Unix command ls in a command shell to present a list of files and directories.
File Names
To see the contents of the file report.txt, use the command cat report.txt.
Programming Language Elements and Literals
Programming language elements include such things as variable names, literals, constants, symbols, tokens, functions, class names, and other objects.
The following line is the output from running ls:
en-US Makefile publican.cfg
Computer Output and Source Code
Notes and Warnings
Finally, I use three visual styles to draw attention to information that might otherwise be overlooked.
Note
Notes are tips, shortcuts, or alternative approaches to the task at hand. Ignoring a note should have no negative consequences, but you might miss out on a trick that makes your life easier.
Important
Important boxes detail things that are easily missed such as configuration changes that apply only to the current session, or services that need restarting before an update will apply. Ignoring a box labeled “Important” will not cause data loss but may cause irritation and frustration.
Warning
Warnings should not be ignored. Ignoring warnings will most likely cause data loss.