import libvirt
from xml.etree import ElementTree as ET
URI = "qemu:///system"
VM = "truffles"
# Get the virDomain object
conn = libvirt.open(URI)
domain_object = conn.lookupByName(VM)
# Get the XML description of the VM
vm_xml = domain_object.XMLDesc(0)
# Get the volume in use from the element tree
root = ET.fromstring(vm_xml)
disk_source = root.find('./devices/disk/source')
volume_in_use = disk_source.get('file')
print volume_in_use
这是我目前找到的解决方案。它使用虚拟机的域名称,返回该域使用的卷的绝对路径。在
相关问题 更多 >
编程相关推荐