Product SiteDocumentation Site

Version 1.2

Libvirt Application Development Guide Using Python

A guide to libvirt application development with Python

Edition 1

Libvirt Development Team

W. David Ashley

Fedora Documentation Team

Daniel Berrange

Red Hat Engineering, Virtualization

Chris Lalancette

Red Hat Engineering, Virtualization

Laine Stump

Red Hat Engineering, Virtualization

Daniel Veillard

Red Hat Engineering, Virtualization

Dani Coulson

Red Hat Engineering Content Services

David Jorm

Red Hat Engineering Content Services

Scott Radvan

Red Hat Engineering Content Services

Stephanos Charalambous

N/A Contributor

Legal Notice

Copyright © 2015-2020 Fedora Project
Copyright © 2009-2010 Red Hat, Inc. and others.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. The original authors of this document, and Red Hat, designate the libvirt Project as the "Attribution Party" for purposes of CC-BY-SA. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
All other trademarks are the property of their respective owners.

Abstract

This document provides a guide for libvirt application developers using python.
Preface
1. Document Conventions
1.1. Typographic Conventions
1.2. Pull-quote Conventions
1.3. Notes and Warnings
2. We Need Feedback!
1. Introduction
1.1. Overview
1.2. Glossary of terms
2. Architecture
2.1. Object model
2.1.1. Hypervisor connections
2.1.2. Guest domains
2.1.3. Virtual networks
2.1.4. Storage pools
2.1.5. Storage volumes
2.1.6. Host devices
2.2. Driver model
2.3. Remote management
2.3.1. Basic usage
2.3.2. Data Transports
2.3.3. Authentication schemes
2.4. Generating TLS certificates
2.4.1. Public Key Infrastructure setup
3. Connections
3.1. Overview
3.1.1. open
3.1.2. openReadOnly
3.1.3. openAuth
3.1.4. close
3.2. URI formats
3.2.1. Local URIs
3.2.2. Remote URIs
3.3. Capability Information Methods
3.4. Host information
3.4.1. getHostname
3.4.2. getMaxVcpus
3.4.3. getInfo
3.4.4. getCellsFreeMemory
3.4.5. getType
3.4.6. Get Library and Driver Versions
3.4.7. getURI
3.4.8. isEncrypted
3.4.9. isSecure
3.4.10. isAlive
3.4.11. compareCPU
3.4.12. getFreeMemory
3.4.13. getFreePages
3.4.14. getMemoryParameters
3.4.15. getMemoryStats
3.4.16. getSecurityModel
3.4.17. getSysinfo
3.4.18. getCPUMap
3.4.19. getCPUStats
3.4.20. getCPUModelNames
4. Guest Domains
4.1. Domain Overview
4.2. Listing Domains
4.3. Obtaining State Information About a Domain
4.3.1. Fetching the ID of a domain
4.3.2. Fetching the UUID of a domain
4.3.3. Fetching the OS type of a domain
4.3.4. Determining if the domain has a current snapshot
4.3.5. Determining if the domain has managed save images
4.3.6. Fetch the hostname of the domain
4.3.7. Get the Domain hardware info
4.3.8. Determine if the Domain is running
4.3.9. Determine if the Domain is persistent
4.3.10. Determine if the Domain is updated
4.3.11. Determine the max memory of the Domain
4.3.12. Determine the max Vcpus of the Domain
4.3.13. Fetch the name of the Domain
4.3.14. Fetch the state of the Domain
4.3.15. Extract the time information from Domain
4.4. Lifecycle Control
4.4.1. Provisioning and Starting
4.4.2. Stopping
4.4.3. Suspend / Resume and Save / Restore
4.4.4. Migration
4.4.5. Autostart
4.5. Domain Configuration
4.5.1. Emulator
4.5.2. Boot Modes
4.5.3. Memory / CPU Resources
4.6. Monitoring Performance
4.6.1. Domain Block Device Performance
4.6.2. vCPU Performance
4.6.3. Memory Statistics
4.6.4. I/O Statistics
4.7. Device configuration
4.7.1. Disks
4.7.2. Networking
4.7.3. Mice, Keyboard & Tablets
4.7.4. USB Device Passthrough
4.7.5. PCI device passthrough
4.8. Live Configuration Change
4.8.1. Block Device Jobs
5. Storage Pools
5.1. Overview
5.2. Listing pools
5.3. Pool usage
5.4. Lifecycle control
5.5. Discovering pool sources
5.6. Pool configuration
5.7. Volume overview
5.8. Listing volumes
5.9. Volume information
5.10. Creating and deleting volumes
5.11. Cloning volumes
6. Virtual Networks
6.1. Overview
6.2. Listing networks
6.3. Lifecycle control
6.4. Network configuration
7. Network Interfaces
7.1. Overview
7.2. XML Interface Description Format
7.3. Retrieving Information About Interfaces
7.3.1. Enumerating Interfaces
7.3.2. Obtaining a virInterface instance for an Interface
7.3.3. Retrieving Detailed Interface Information
7.3.4. Retrieving Interface Network Addresses
7.4. Managing interface configuration files
7.4.1. Defining an interface configuration
7.4.2. Undefining an interface configuration
7.4.3. changeRollback
7.4.4. changeBegin
7.4.5. changeCommit
7.5. Interface lifecycle management
7.5.1. Activating an interface
7.5.2. Deactivating an interface
8. Error Handling
8.1. virGetLastError
8.2. Subclassing libvirtError
8.3. Registering an Error Handler Function
9. Event and Timer Handling
9.1. Event Handling
9.2. Timer Handling
10. Security Model
11. Debugging / Logging
11.1. Environment Variables
12. Usage Examples
12.1. Zero to Virtual Appliance
12.2. Taking a Screenshot
A. Revision History
Index