storagePoolCreateXML
method should always be 0
.
Example 5.5. Discover a storage pool's sources
# Example-5.py #!/usr/bin/env python3 import sys import libvirt from xml.dom import minidom poolName = 'default' conn = None try: conn = libvirt.open("qemu:///system") except libvirt.libvirtError as e: print(repr(e), file=sys.stderr) exit(1) sp = conn.storagePoolLookupByName(poolName) if sp == None: print('Failed to find storage pool '+poolName, file=sys.stderr) exit(1) raw_xml = sp.XMLDesc(0) xml = minidom.parseString(raw_xml) name = xml.getElementsByTagName('name') print('pool name: '+poolName) spTypes = xml.getElementsByTagName('source') for spType in spTypes: attr = spType.getAttribute('name') if attr != None: print(' name = '+attr) attr = spType.getAttribute('path') if attr != None: print(' path = '+attr) attr = spType.getAttribute('dir') if attr != None: print(' dir = '+attr) attr = spType.getAttribute('type') if attr != None: print(' type = '+attr) attr = spType.getAttribute('username') if attr != None: print(' username = '+attr) conn.close() exit(0)