[libvirt-users] virDomainBlockInfo for local volume

Shahar Havivi shavivi at redhat.com
Wed Nov 30 13:13:08 UTC 2016


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




More information about the libvirt-users mailing list