I'm using KVM to live migrate VMs from one host to another. I have already written a web ui to do that. Now I want to implement a progress bar.
My idea is to compare the file size of the disk on the source and on the target while it's migrating.
ls -ls /data/file.raw 858963 -rw------- 1 root root 21474836480 Dec 15 13:39 file.raw
ls -ls /data/file.raw 698543 -rw------- 1 root root 21474836480 Dec 15 13:39 file.raw
Now, I took the allocated value and calculated it in percent.
100 / 858963 * 698543 = 81%
Fine. but there is one problem:
The disk is not sparse. The total size of the file is
Actually, there are only
858963 blocks allocated. So the live migration is still copying the empty parts of the file while my progress bar is already at 100%
I already tried around with
How to get only the transferred file size of the disk?