Skip to main content

2019 | Buch

Foundations of Libvirt Development

How to Set Up and Maintain a Virtual Machine Environment with Python

insite
SUCHEN

Über dieses Buch

Discover the essential concepts of libvirt development and see how to interface to Linux virtualization environments, such as QEMU/KVM, XEN, Virtuozzo, VMWare ESX, LXC, Bhyve, and more. This book will prepare you to set up and maintain a virtual machine environment.
You'll start by reviewing virtualization in general and then move on to libvirt-specific concepts using Python, including virtualized operating systems and networks, connections, storage pools, and event and error handling. This work concludes with a comprehensive look at the XML schema definitions for domains, networks, devices, network filtering, storage, node devices, and more.
The libvirt API covers the entire life cycle of virtual objects, from creation to destruction. It contains everything needed for the management of a virtual object during that life cycle. While libvirt has APIs that support many languages, Foundations of Libvirt Development concentrates on Python exclusively, and how to use the APIs to control virtual machines under the QEMU/KVM system. and more.


What You'll Learn
Interface Python to the libvirt library.
Review the class layout and methods of the libvirt library.
Install and manipulate virtual machines via Python/libvirt.
Create XML to manipulate domains, networks, and devices.
Write Python programs to perform libvirt functions without human intervention.Who This Book Is For​Maintainers of virtual machines in a UNIX/Linux environment ranging from managing code on a single virtual machine through an entire installation of virtual machines.

Inhaltsverzeichnis

Frontmatter
Chapter 1. Introduction
Abstract
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.
W. David Ashley
Chapter 2. Architecture
Abstract
This chapter describes the main principles and architecture choices behind the libvirt API and the Python libvirt module. These include the object model, the driver model, and management options. The details of these models and options are described in this chapter.
W. David Ashley
Chapter 3. Connecting to Domains
Abstract
As mentioned in the previous chapter, a connection is the foundation of every action and object in the libvirt system. Every entity that wants to interact with libvirt, be it virsh, virt-manager, or a program using the libvirt library, needs to first obtain a connection to the libvirt daemon on the host node it is interested in. A connection describes not only the type of virtualization technology that the agent wants to interact with (qemu, xen, uml, etc.) but also any authentication methods necessary to connect to that resource.
W. David Ashley
Chapter 4. Guest Domains
Abstract
A domain is a reference to a running or nonrunning virtual operating system under libvirt. As many domains as necessary can be created/installed under libvirt up to the limit imposed by either the system administrator or the number that can be supported without performance penalties on the host system. This number will vary depending on the performance abilities of the host system.
W. David Ashley
Chapter 5. Storage Pools and Volumes
Abstract
libvirt provides storage management on the physical host through storage pools and volumes. Storage pools and volumes can be located on the main host or remotely via NFS mounts on the host. Storage pools are areas of storage set aside to contain volumes. Volumes are directly used by client domains for file system storage and are formatted by the client domain. A volume can contain any type of domain client partition type(s) and is controlled strictly by the domain client. A volume is always a member of a single storage pool. However, a domain can have access to multiple client volumes as long as none of those volumes is shared with any other active client domains; this is because there are no facilities in libvirt to share volumes between domains.
W. David Ashley
Chapter 6. Virtual Networks
Abstract
A virtual network provides a method for connecting the network devices of one or more guest domains within a single host. The virtual network can do either of the following:
W. David Ashley
Chapter 7. Network Interfaces
Abstract
You can configure network interfaces on physical hosts with the methods in the virInterface class. This is useful for setting up the host to share one physical interface between the multiple guest domains that you want connected directly to the network (briefly, you can enslave a physical interface to the bridge and then create a tap device for each VM that is sharing the interface), as well as for general host network interface management. In addition to configuring the physical hardware, you can use the methods to configure bridges, bonded interfaces, and VLAN interfaces.
W. David Ashley
Chapter 8. Error Handling
Abstract
The libvirt error functions are designed to give more detailed information about what caused a failure in the case that a normal libvirt function or method returns an error. An important thing to note about Python libvirt error reporting is that errors are stored on a per-thread basis and not per connection.
W. David Ashley
Chapter 9. Event and Timer Handling
Abstract
The Python libvirt module provides a complete interface for handling both events and timers. Both event handling and timer handling are invoked through a function interface as opposed to a class/method interface. This makes it easier to integrate the interface into either a graphical or console program.
W. David Ashley
Chapter 10. Using the QEMU Guest Agent
Abstract
When the libvirt project was first released, the scope was limited to the external control of guest domains. It became clear in a short time that to fully administer a guest domain it would be necessary to communicate with the domain operating system to query dynamic runtime information and issue commands to the OS.
W. David Ashley
Chapter 11. Debugging/Logging
Abstract
This chapter covers the debugging and logging APIs in libvirt. This should supply you with enough information to solve runtime problems that sometimes occur with libvirt. Although the example programs in this book do not show how to incorporate debugging and logging in your program, there is enough information presented here to make that task easy enough.
W. David Ashley
Chapter 12. A Sample Problem
Abstract
This chapter introduces a sample problem. This problem can be solved through the use of multiple guest domains (virtual machines) and some automation programs. You will see some alternatives to solving a problem using automation. This will help prepare you to solve similar problems in your own environment.
W. David Ashley
Chapter 13. Storing Information About Virtual Machines
Abstract
There are two categories of information that need to be obtained and stored to be able to manipulate and use guest domains.
W. David Ashley
Chapter 14. Securing Virtual Machines
Abstract
In this chapter, you’ll quickly review host and guest domain security.
W. David Ashley
Backmatter
Metadaten
Titel
Foundations of Libvirt Development
verfasst von
W. David Ashley
Copyright-Jahr
2019
Verlag
Apress
Electronic ISBN
978-1-4842-4862-1
Print ISBN
978-1-4842-4861-4
DOI
https://doi.org/10.1007/978-1-4842-4862-1