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