[libvirt-users] Create volume wit libvirt API for Python

Anatoliy Guskov anatoliy.guskov at gmail.com
Sat Aug 6 20:34:29 UTC 2011


Please help! How create volume with libvirt API for python?

conn = libvirt.open(qemu:///system)
vol = libvirt.virStoragePool(conn)
conf_file = 'disk.xml'
f = open(conf_file)
xml = f.read()
pool = "default"
vol.createXML(pool,xml)

xml file disk.xml:
<volume>
<name>name.img</name>
<key>/var/lib/libvirt/images/name.img</key>
<source>
</source>
<capacity>21474836480</capacity>
<allocation>21474840576</allocation>
<target>
<path>/var/lib/libvirt/images/name.img</path>
<format type='raw'/>
</target>
</volume>

This script not work :-(

Thanks for help!




More information about the libvirt-users mailing list