/usr/share/doc/libvirt-devel-version/
if your system has the libvirt-devel package installed.
XMLDesc
method. This method returns the current description of a domain as an XML data stream. This stream can then be parsed to obtain detailed information about the domain and all the parts that make up the domain.
VIR_DOMAIN_XML_SECURE |
VIR_DOMAIN_XML_INACTIVE |
VIR_DOMAIN_XML_UPDATE_CPU |
VIR_DOMAIN_XML_MIGRATABLE |
Example 4.35. Get basic domain information from the domain's XML description
# Example-36.py #!/usr/bin/env python3 import sys import libvirt from xml.dom import minidom domName = 'Fedora22-x86_64-1' conn = None try: conn = libvirt.open("qemu:///system") except libvirt.libvirtError as e: print(repr(e), file=sys.stderr) exit(1) dom = conn.lookupByID(5) if dom == None: print('Failed to find the domain '+domName, file=sys.stderr) exit(1) raw_xml = dom.XMLDesc(0) xml = minidom.parseString(raw_xml) domainTypes = xml.getElementsByTagName('type') for domainType in domainTypes: print(domainType.getAttribute('machine')) print(domainType.getAttribute('arch')) conn.close() exit(0)
Example 4.36. Get domain's emulator information
# Example-37.py #!/usr/bin/env python3 import sys import libvirt from xml.dom import minidom domName = 'Fedora22-x86_64-1' conn = None try: conn = libvirt.open("qemu:///system") except libvirt.libvirtError as e: print(repr(e), file=sys.stderr) exit(1) dom = conn.lookupByID(5) if dom == None: print('Failed to find the domain '+domName, file=sys.stderr) exit(1) raw_xml = dom.XMLDesc(0) xml = minidom.parseString(raw_xml) domainEmulator = xml.getElementsByTagName('emulator') print('emulator: '+domainEmulator[0].firstChild.data) conn.close() exit(0)
Example 4.37. Domain Emulator XML information
<domain type='kvm'> ... <emulator>/usr/libexec/qemu-kvm</emulator> ... </domain>