Ping

On Wed, Nov 30, 2016 at 3:13 PM, Shahar Havivi <shavivi@redhat.com> wrote:
Hi,

I am using virStorageVolGetInfo to get the volume size virStorageVol.download to download a
normal file for VDSM project.

I want to add support for block devices as well, I was able to see the size
via virDomainBlockInfo and download via virDomain.blockPeek which is works
fine for both file and block device.

1. Can I depend on virDomainBlockInfo for non block devices?
2. Does the virDomainBlockInfo return the correct physical size for normal file?
3. Performance wise do we have a difference between virStorageVol.download and virDomain.blockPeek?


Assuming the VMs are down, this is the code I intend to use for all formats:

vm = con.lookupByName(options.vmname)
info = vm.blockInfo(src)
physical = info[2]

off = 0
size = 0
with open(dest, 'w+') as f:
    while off < physical:
        if (physical - off) < bufsize:
            size = physical - off
        else:
            size = bufsize
        buf = vm.blockPeek(src, off, size)
        f.write(buf)
        off += size