[Libguestfs] [PATCH v5] v2v: Add --print-estimate option to print copy size estimate.
Pino Toscano
ptoscano at redhat.com
Fri Aug 24 09:55:30 UTC 2018
On Thursday, 23 August 2018 20:13:21 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
> 1 1047920640
> total 1047920640
Maybe having a slightly more user friendly output in non-machine
readable mode would be nice...
> + 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
let chan, json = Filename.open_temp_file "v2vmeasure" ".json" in
unlink_on_exit json;
let fd = Unix.descr_of_out_channel chan in
> + let json = read_whole_file json in
> + debug "qemu-img measure output: %s" json;
> + let json = json_parser_tree_parse json in
I just pushed json_parser_tree_parse_file, so that can be used instead
using read_whole_file.
> +echo -n "Estimate: "
> +cat $f
> +
> +# Check the output looks reasonable.
> +grep -E 'total.*[[:digit:]]+' $f
Maybe using a tool like jd to check the keys in the JSON dict would
be cleaner.
--
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/20180824/517ade68/attachment.sig>
More information about the Libguestfs
mailing list