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