[Libguestfs] [PATCH v4] v2v: Add --print-estimate option to print copy size estimate.

Pino Toscano ptoscano at redhat.com
Thu Aug 23 16:46:59 UTC 2018


On Thursday, 23 August 2018 17:59:36 CEST Richard W.M. Jones wrote:
> This option prints the estimated size of the data that will be copied
> from the source disk.
> 
> Currently this overestimates by the size of the qcow2 header, but for
> real disk images that doesn't matter much.
> 
> For example:
> 
> $ virt-builder fedora-27
> $ virt-v2v -i disk fedora-27.img -o null --print-estimate
> [...]
> virt-v2v: This guest has virtio drivers installed.
> [  44.0] Mapping filesystem data to avoid copying unused and blank areas
> [  44.5] Closing the overlay
> 1047920640

IMHO a better output is similar to what the --print-source prints --
so for example something like:

Estimation of the disks of the guest:
     Total size: 100000
         disk 1: 50000
         disk 2: 50000

While the --machine-readable a JSON snippet:

{
  "total": 100000,
  "disks": [
    50000,
    50000
  ]
}

IMHO providing the sizes of all the disks is a good idea, so it is
possible to do better estimation on the progress, in case.  Imagine
if a VM has a much bigger disk than the others, for example.
Also, I'd do the same no matter the number of disks, for coherency.

> +  let json = Filename.temp_file "v2vmeasure" ".json" in
> +  unlink_on_exit json;
> +
> +  let fd = Unix.openfile json [O_WRONLY; O_CREAT; O_TRUNC] 0o600 in

IMHO these can be replaced by Filename.open_temp_file +
Unix.descr_of_in_channel (still with unlink_on_exit).

-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20180823/2e8971b1/attachment.sig>


More information about the Libguestfs mailing list