Richard W.M. Jones
2018-Mar-15 17:37 UTC
[Libguestfs] [PATCH 0/2] v2v: Add --print-target to display overlay and target information.
RHV was connecting to the VMware source in order to find out the virtual disk size of the source disk(s), duplicating logic that virt-v2v already provides. This makes that information available using a new ‘virt-v2v --print-target option’. Note in order to get all the information, this has to actually perform the conversion step, so it takes 30 seconds or so before we reach the point where the information gets printed. We could also add a more easily parsable version of this data ... Rich.
Richard W.M. Jones
2018-Mar-15 17:37 UTC
[Libguestfs] [PATCH 1/2] v2v: Update target.target_estimated_size in targets list in main function.
The rebasing in commit 5dae9ca23dab90dfb890f6663aa4bacf1df31ced caused this field to never get updated. --- v2v/v2v.ml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/v2v/v2v.ml b/v2v/v2v.ml index f494defcf..75936c501 100644 --- a/v2v/v2v.ml +++ b/v2v/v2v.ml @@ -113,11 +113,12 @@ let rec main () let mpstats = get_mpstats g in check_guest_free_space mpstats; - (match conversion_mode with - | Copying (_, targets) -> - check_target_free_space mpstats source targets output - | In_place -> () - ); + let conversion_mode + match conversion_mode with + | Copying (overlays, targets) -> + let targets = check_target_free_space mpstats source targets output in + Copying (overlays, targets) + | In_place -> In_place in (* Conversion. *) let guestcaps @@ -598,7 +599,8 @@ and check_target_free_space mpstats source targets output message (f_"Estimating space required on target for each disk"); let targets = estimate_target_size mpstats targets in - output#check_target_free_space source targets + output#check_target_free_space source targets; + targets (* Conversion. *) and do_convert g inspect source output rcaps -- 2.13.2
Richard W.M. Jones
2018-Mar-15 17:37 UTC
[Libguestfs] [PATCH 2/2] v2v: Add --print-target to display overlay and target information.
This is analogous to --print-source, except that it prints the overlay and target disk information. The output looks like below. Note there is one overlay and one target section per disk. Overlay and Target information (--print-target option): overlay file: /home/rjones/d/libguestfs/tmp/v2vovlc687fe.qcow2 overlay device name: sda overlay virtual disk size: 6442450944 overlay source qemu URI: /var/tmp/fedora-27.img target file: [qemu] json:{ "file.driver": "nbd", "file.path": "/home/rjones/d/libguestfs/tmp/rhvupload.IWrzO6/nbdkit0.sock", "file.export": "/" } target format: raw target estimated size: 2274060540 --- v2v/cmdline.ml | 14 +++++++++++++- v2v/cmdline.mli | 1 + v2v/types.ml | 20 +++++++------------- v2v/v2v.ml | 17 +++++++++++++++++ v2v/virt-v2v.pod | 5 +++++ 5 files changed, 43 insertions(+), 14 deletions(-) diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml index 4f651825a..6aba4afb5 100644 --- a/v2v/cmdline.ml +++ b/v2v/cmdline.ml @@ -44,6 +44,7 @@ type cmdline = { output_format : string option; output_name : string option; print_source : bool; + print_target : bool; root_choice : root_choice; } @@ -53,6 +54,7 @@ let parse_cmdline () let do_copy = ref true in let machine_readable = ref false in let print_source = ref false in + let print_target = ref false in let qemu_boot = ref false in let input_conn = ref None in @@ -233,6 +235,8 @@ let parse_cmdline () s_"Use password from file"; [ L"print-source" ], Getopt.Set print_source, s_"Print source and stop"; + [ L"print-target" ], Getopt.Set print_target, + s_"Print target and stop"; [ L"qemu-boot" ], Getopt.Set qemu_boot, s_"Boot in qemu (-o qemu only)"; [ L"rhv-cafile" ], Getopt.String ("ca.pem", set_string_option_once "--rhv-cafile" rhv_cafile), s_"For -o rhv-upload, set ‘ca.pem’ file"; @@ -330,6 +334,7 @@ read the man page virt-v2v(1). let output_storage = !output_storage in let password_file = !password_file in let print_source = !print_source in + let print_target = !print_target in let qemu_boot = !qemu_boot in let rhv_cafile = !rhv_cafile in let rhv_direct = !rhv_direct in @@ -371,6 +376,12 @@ read the man page virt-v2v(1). exit 0 ); + (* Some options cannot be used with --in-place. *) + if in_place then ( + if print_target then + error (f_"--in-place and --print-target cannot be used together") + ); + (* Parse out the password from the password file. *) let password match password_file with @@ -620,6 +631,7 @@ read the man page virt-v2v(1). do_copy = do_copy; in_place = in_place; network_map = network_map; output_alloc = output_alloc; output_format = output_format; output_name = output_name; - print_source = print_source; root_choice = root_choice; + print_source = print_source; print_target; + root_choice = root_choice; }, input, output diff --git a/v2v/cmdline.mli b/v2v/cmdline.mli index 7d88f0f54..0e1d54f40 100644 --- a/v2v/cmdline.mli +++ b/v2v/cmdline.mli @@ -42,6 +42,7 @@ type cmdline = { output_format : string option; output_name : string option; print_source : bool; + print_target : bool; root_choice : Types.root_choice; } diff --git a/v2v/types.ml b/v2v/types.ml index b89bd2fe2..c1f36fdb1 100644 --- a/v2v/types.ml +++ b/v2v/types.ml @@ -281,11 +281,10 @@ type overlay = { } let string_of_overlay ov - sprintf "\ -ov_overlay_file = %s -ov_sd = %s -ov_virtual_size = %Ld -ov_source = %s + sprintf " overlay file: %s + overlay device name: %s +overlay virtual disk size: %Ld + overlay source qemu URI: %s " ov.ov_overlay_file ov.ov_sd @@ -304,12 +303,9 @@ and target_file | TargetURI of string let string_of_target t - sprintf "\ -target_file = %s -target_format = %s -target_estimated_size = %s -target_overlay = %s -target_overlay.ov_source = %s + sprintf " target file: %s + target format: %s +target estimated size: %s " (match t.target_file with | TargetFile s -> "[file] " ^ s @@ -317,8 +313,6 @@ target_overlay.ov_source = %s t.target_format (match t.target_estimated_size with | None -> "None" | Some i -> Int64.to_string i) - t.target_overlay.ov_overlay_file - t.target_overlay.ov_source.s_qemu_uri type target_firmware = TargetBIOS | TargetUEFI diff --git a/v2v/v2v.ml b/v2v/v2v.ml index 75936c501..abb531c6f 100644 --- a/v2v/v2v.ml +++ b/v2v/v2v.ml @@ -150,6 +150,22 @@ let rec main () g#shutdown (); g#close (); + (match conversion_mode with + | In_place -> () + | Copying (overlays, targets) -> + (* Print overlays/targets and stop. *) + if cmdline.print_target then ( + printf (f_"Overlay and Target information (--print-target option):\n"); + printf "\n"; + List.iter ( + fun (ov, t) -> + printf "%s\n" (string_of_overlay ov); + printf "%s\n" (string_of_target t) + ) (List.combine overlays targets); + exit 0 + ) + ); + (* Copy overlays to target (for [--in-place] this does nothing). *) (match conversion_mode with | In_place -> () @@ -685,6 +701,7 @@ and copy_targets cmdline targets input output message (f_"Copying disk %d/%d to qemu URI %s (%s)") (i+1) nr_disks s t.target_format ); + debug "%s" (string_of_overlay t.target_overlay); debug "%s" (string_of_target t); (* We noticed that qemu sometimes corrupts the qcow2 file on diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod index faf8c0ba2..bbd6985e4 100644 --- a/v2v/virt-v2v.pod +++ b/v2v/virt-v2v.pod @@ -631,6 +631,11 @@ Print information about the source guest and stop. This option is useful when you are setting up network and bridge maps. See L</NETWORKS AND BRIDGES>. +=item B<--print-target> + +Print information about the target disk(s) and overlay file(s), and +stop. + =item B<--qemu-boot> When using I<-o qemu> only, this boots the guest immediately after -- 2.13.2
Tomáš Golembiovský
2018-Mar-16 11:29 UTC
Re: [Libguestfs] [PATCH 2/2] v2v: Add --print-target to display overlay and target information.
On Thu, 15 Mar 2018 17:37:46 +0000 "Richard W.M. Jones" <rjones@redhat.com> wrote:> This is analogous to --print-source, except that it prints the overlay > and target disk information. > > The output looks like below. Note there is one overlay and one target > section per disk. > > Overlay and Target information (--print-target option): > > overlay file: /home/rjones/d/libguestfs/tmp/v2vovlc687fe.qcow2 > overlay device name: sda > overlay virtual disk size: 6442450944 > overlay source qemu URI: /var/tmp/fedora-27.img > > target file: [qemu] json:{ "file.driver": "nbd", "file.path": "/home/rjones/d/libguestfs/tmp/rhvupload.IWrzO6/nbdkit0.sock", "file.export": "/" } > target format: raw > target estimated size: 2274060540 > --- > v2v/cmdline.ml | 14 +++++++++++++- > v2v/cmdline.mli | 1 + > v2v/types.ml | 20 +++++++------------- > v2v/v2v.ml | 17 +++++++++++++++++ > v2v/virt-v2v.pod | 5 +++++ > 5 files changed, 43 insertions(+), 14 deletions(-) > > diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml > index 4f651825a..6aba4afb5 100644 > --- a/v2v/cmdline.ml > +++ b/v2v/cmdline.ml > @@ -44,6 +44,7 @@ type cmdline = { > output_format : string option; > output_name : string option; > print_source : bool; > + print_target : bool; > root_choice : root_choice; > } > > @@ -53,6 +54,7 @@ let parse_cmdline () > let do_copy = ref true in > let machine_readable = ref false in > let print_source = ref false in > + let print_target = ref false in > let qemu_boot = ref false in > > let input_conn = ref None in > @@ -233,6 +235,8 @@ let parse_cmdline () > s_"Use password from file"; > [ L"print-source" ], Getopt.Set print_source, > s_"Print source and stop"; > + [ L"print-target" ], Getopt.Set print_target, > + s_"Print target and stop"; > [ L"qemu-boot" ], Getopt.Set qemu_boot, s_"Boot in qemu (-o qemu only)"; > [ L"rhv-cafile" ], Getopt.String ("ca.pem", set_string_option_once "--rhv-cafile" rhv_cafile), > s_"For -o rhv-upload, set ‘ca.pem’ file"; > @@ -330,6 +334,7 @@ read the man page virt-v2v(1). > let output_storage = !output_storage in > let password_file = !password_file in > let print_source = !print_source in > + let print_target = !print_target in > let qemu_boot = !qemu_boot in > let rhv_cafile = !rhv_cafile in > let rhv_direct = !rhv_direct in > @@ -371,6 +376,12 @@ read the man page virt-v2v(1). > exit 0 > ); > > + (* Some options cannot be used with --in-place. *) > + if in_place then ( > + if print_target then > + error (f_"--in-place and --print-target cannot be used together") > + ); > + > (* Parse out the password from the password file. *) > let password > match password_file with > @@ -620,6 +631,7 @@ read the man page virt-v2v(1). > do_copy = do_copy; in_place = in_place; network_map = network_map; > output_alloc = output_alloc; output_format = output_format; > output_name = output_name; > - print_source = print_source; root_choice = root_choice; > + print_source = print_source; print_target;Not print_target = print_target? Otherwise LGTM. Tomas -- Tomáš Golembiovský <tgolembi@redhat.com>
Reasonably Related Threads
- [PATCH v2 0/5] Add --print-target with machine-readable version.
- Re: [PATCH 2/2] v2v: Add --print-target to display overlay and target information.
- [PATCH v2 00/17] v2v: add --in-place mode
- [PATCH v4 0/3] v2v: add --in-place mode
- Re: [PATCH v2 15/17] v2v: add --in-place mode