[Pkg-libvirt-commits] [libguestfs] 06/17: v2v: Add --debug-overlays option.
Hilko Bengen
bengen at moszumanska.debian.org
Fri Oct 3 14:48:30 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag debian/1%1.27.55-1
in repository libguestfs.
commit 03ef91aa46e036b84a687a7c891720aeea651a17
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Fri Sep 26 10:06:00 2014 +0100
v2v: Add --debug-overlays option.
You can use this to accelerate testing:
$ virt-v2v --no-copy --debug-overlays [etc]
[...]
[ 82.0] Converting Windows 7 Ultimate to run on KVM
This guest has virtio drivers installed.
[ 86.0] Closing the overlay
[ 91.0] Creating output metadata
Overlay saved as /var/tmp/win7-test-sda.qcow2 [--debug-overlays]
[ 91.0] Finishing off
No disk format conversion/copying is done, so it's very fast.
The overlay file is preserved and can be tested directly (it uses the
source file as backing).
---
v2v/cmdline.ml | 8 +++++++-
v2v/v2v.ml | 20 ++++++++++++++++----
v2v/virt-v2v.pod | 6 ++++++
3 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
index 1e059fc..26409d2 100644
--- a/v2v/cmdline.ml
+++ b/v2v/cmdline.ml
@@ -33,6 +33,7 @@ let parse_cmdline () =
in
let debug_gc = ref false in
+ let debug_overlays = ref false in
let do_copy = ref true in
let input_conn = ref "" in
let input_format = ref "" in
@@ -122,6 +123,10 @@ let parse_cmdline () =
let argspec = Arg.align [
"--bridge", Arg.String add_bridge, "in:out " ^ s_"Map bridge 'in' to 'out'";
"--debug-gc",Arg.Set debug_gc, " " ^ s_"Debug GC and memory allocations";
+ "--debug-overlay",Arg.Set debug_overlays,
+ " " ^ s_"Save overlay files";
+ "--debug-overlays",Arg.Set debug_overlays,
+ ditto;
"-i", Arg.String set_input_mode, i_options ^ " " ^ s_"Set input mode (default: libvirt)";
"-ic", Arg.Set_string input_conn, "uri " ^ s_"Libvirt URI";
"-if", Arg.Set_string input_format,
@@ -184,6 +189,7 @@ read the man page virt-v2v(1).
(* Dereference the arguments. *)
let args = List.rev !args in
let debug_gc = !debug_gc in
+ let debug_overlays = !debug_overlays in
let do_copy = !do_copy in
let input_conn = match !input_conn with "" -> None | s -> Some s in
let input_format = match !input_format with "" -> None | s -> Some s in
@@ -347,6 +353,6 @@ read the man page virt-v2v(1).
vmtype output_alloc in
input, output,
- debug_gc, do_copy, network_map,
+ debug_gc, debug_overlays, do_copy, network_map,
output_alloc, output_format, output_name,
print_source, quiet, root_choice, trace, verbose
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index becc27c..7227960 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -40,7 +40,7 @@ let () = Random.self_init ()
let rec main () =
(* Handle the command line. *)
let input, output,
- debug_gc, do_copy, network_map,
+ debug_gc, debug_overlays, do_copy, network_map,
output_alloc, output_format, output_name,
print_source, quiet, root_choice, trace, verbose =
Cmdline.parse_cmdline () in
@@ -101,11 +101,12 @@ let rec main () =
* data over the wire.
*)
msg (f_"Creating an overlay to protect the source from being modified");
+ let overlay_dir = (new Guestfs.guestfs ())#get_cachedir () in
let overlays =
List.map (
fun ({ s_qemu_uri = qemu_uri; s_format = format } as source) ->
- let temp_dir = (new Guestfs.guestfs ())#get_cachedir () in
- let overlay_file = Filename.temp_file ~temp_dir "v2vovl" ".qcow2" in
+ let overlay_file =
+ Filename.temp_file ~temp_dir:overlay_dir "v2vovl" ".qcow2" in
unlink_on_exit overlay_file;
let options =
@@ -243,7 +244,7 @@ let rec main () =
printf (f_"This guest does not have virtio drivers installed.\n%!");
);
- if do_copy then (
+ if do_copy || debug_overlays then (
(* Doing fstrim on all the filesystems reduces the transfer size
* because unused blocks are marked in the overlay and thus do
* not have to be copied.
@@ -336,6 +337,17 @@ let rec main () =
msg (f_"Creating output metadata");
output#create_metadata source targets guestcaps inspect;
+ (* Save overlays if --debug-overlays option was used. *)
+ if debug_overlays then (
+ List.iter (
+ fun ov ->
+ let saved_filename =
+ sprintf "%s/%s-%s.qcow2" overlay_dir source.s_name ov.ov_sd in
+ rename ov.ov_overlay_file saved_filename;
+ printf (f_"Overlay saved as %s [--debug-overlays]\n") saved_filename
+ ) overlays
+ );
+
msg (f_"Finishing off");
delete_target_on_exit := false; (* Don't delete target on exit. *)
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
index d90ad1b..8e45d77 100644
--- a/v2v/virt-v2v.pod
+++ b/v2v/virt-v2v.pod
@@ -161,6 +161,12 @@ Debug garbage collection and memory allocation. This is only useful
when debugging memory problems in virt-v2v or the OCaml libguestfs
bindings.
+=item B<--debug-overlays>
+
+Save the overlay file(s) created during conversion. This option is
+only used for debugging virt-v2v and may be removed in a future
+version.
+
=item B<-i disk>
Set the input method to I<disk>.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list