© W. David Ashley 2019
W. David AshleyFoundations of Libvirt Development https://doi.org/10.1007/978-1-4842-4862-1_1

1. Introduction

W. David Ashley1 
(1)
Austin, TX, USA
 

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

Computer commands are usually presented in bold text such as in the following example:
  • Run the Unix command ls in a command shell to present a list of files and directories.

File Names

File names are usually presented in monospaced text such as in the following example:
  • 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.

Literal data is usually taken directly from a computer screen or a computer language literal value and presented in monospaced text such as in the following example:
  • The following line is the output from running ls:

  • en-US Makefile publican.cfg

Computer Output and Source Code

Computer output data is usually taken directly from a computer screen and presented in monospaced text such as in the following example.
books        Desktop   documentation  drafts  mss    photos   stuff  svn
books_tests  Desktop1  downloads      images  notes  scripts  svgs   libvirt
Source code listings are also set off from the rest of the text as follows:
from __future__ import print_function
import sys
import libvirt
conn = libvirt.open('qemu:///system')
if conn == None:
    print('Failed to open connection to qemu:///system',
          file=sys.stderr)
    exit(1)
conn.close()
exit(0)

Notes and Warnings

Finally, I use three visual styles to draw attention to information that might otherwise be overlooked.

../images/478111_1_En_1_Chapter/478111_1_En_1_Figa_HTML.gifNote

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.

../images/478111_1_En_1_Chapter/478111_1_En_1_Figb_HTML.gifImportant

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.

../images/478111_1_En_1_Chapter/478111_1_En_1_Figc_HTML.gifWarning

Warnings should not be ignored. Ignoring warnings will most likely cause data loss.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.202.45