On 04/17/2017 01:32 PM, Vasiliy Tolstov wrote: > 2017-04-17 14:08 GMT+03:00 Michal Privoznik <mprivozn@xxxxxxxxxx>: >> Before digging into implementation of a new functionality we should >> check if the functionality is not already there. I mean - that 'virsh >> vol-create-from' or libvirt.virStoragePool.createXMLFrom() or >> virStorageVolCreateXMLFrom() - they should serve exactly what you need. >> Don't they? >> >> If not, then yes - we might focus on adding new API for that. > > > This function now work across pools. So two volumes need to be in the > same pool. But i need to copy across pools > Is that right? Here I'm successfully cloning a volume across two storage pools: $ ipython Python 3.4.5 (default, Mar 23 2017, 19:22:46) Type "copyright", "credits" or "license" for more information. IPython 3.2.1 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: import libvirt In [2]: conn=libvirt.open("qemu:///system") In [3]: poolD=conn.storagePoolLookupByName("default") In [4]: poolT=conn.storagePoolLookupByName("tmp") In [5]: volF=poolD.storageVolLookupByName("fedora.qcow2") In [6]: poolT.createXMLFrom? Signature: poolT.createXMLFrom(xmlDesc, clonevol, flags=0) Docstring: Create a storage volume in the parent pool, using the 'clonevol' volume as input. Information for the new volume (name, perms) are passed via a typical volume XML description. Since 1.0.1 VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA in flags can be used to get higher performance with qcow2 image files which don't support full preallocation, by creating a sparse image file with metadata. virStorageVolFree should be used to free the resources after the storage volume object is no longer needed. File: /usr/lib64/python3.4/site-packages/libvirt.py Type: method In [7]: volF.XMLDesc() Out[7]: "<volume type='file'>\n <name>fedora.qcow2</name>\n <key>/var/lib/libvirt/images/fedora.qcow2</key>\n <source>\n </source>\n <capacity unit='bytes'>21474836480</capacity>\n <allocation unit='bytes'>15330648064</allocation>\n <physical unit='bytes'>15330770944</physical>\n <target>\n <path>/var/lib/libvirt/images/fedora.qcow2</path>\n <format type='qcow2'/>\n <permissions>\n <mode>0644</mode>\n <owner>0</owner>\n <group>0</group>\n </permissions>\n <timestamps>\n <atime>1492104221.232529688</atime>\n <mtime>1491985789.153734999</mtime>\n <ctime>1492104221.232529688</ctime>\n </timestamps>\n <compat>1.1</compat>\n <features/>\n </target>\n</volume>\n" In [8]: poolT.createXMLFrom(volF.XMLDesc(), volF, 0) Out[8]: <libvirt.virStorageVol at 0x7fa9fa279ac8> Michal -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list