[Libguestfs] [PATCH 05/14] v2v: Dump out 'source' structure when debugging.

Richard W.M. Jones rjones at redhat.com
Mon Jun 23 11:32:21 UTC 2014


---
 v2v/types.ml  | 24 ++++++++++++++++++++++++
 v2v/types.mli |  3 +++
 v2v/v2v.ml    |  2 ++
 3 files changed, 29 insertions(+)

diff --git a/v2v/types.ml b/v2v/types.ml
index 0f5ae86..9a41f18 100644
--- a/v2v/types.ml
+++ b/v2v/types.ml
@@ -40,6 +40,30 @@ type source = {
 }
 and source_disk = string * string option
 
+let rec string_of_source s =
+  sprintf "\
+s_dom_type = %s
+s_name = %s
+s_memory = %Ld
+s_vcpu = %d
+s_arch = %s
+s_features = [%s]
+s_disks = [%s]
+"
+    s.s_dom_type
+    s.s_name
+    s.s_memory
+    s.s_vcpu
+    s.s_arch
+    (String.concat "," s.s_features)
+    (String.concat "," (List.map string_of_source_disk s.s_disks))
+
+and string_of_source_disk (path, format) =
+  path ^
+    match format with
+    | None -> ""
+    | Some format -> " (" ^ format ^ ")"
+
 type overlay = {
   ov_overlay : string;
   ov_target_file : string;
diff --git a/v2v/types.mli b/v2v/types.mli
index e7e72e0..87ba291 100644
--- a/v2v/types.mli
+++ b/v2v/types.mli
@@ -43,6 +43,9 @@ type source = {
 and source_disk = string * string option
 (** A source file is a qemu URI and a format. *)
 
+val string_of_source : source -> string
+val string_of_source_disk : source_disk -> string
+
 type overlay = {
   ov_overlay : string;       (** Local overlay file (qcow2 format). *)
   ov_target_file : string;   (** Destination file (real). *)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index fd6c049..838354f 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -45,6 +45,8 @@ let rec main () =
     | InputLibvirtXML filename ->
       Source_libvirt.create_from_xml filename in
 
+  if verbose then printf "%s%!" (string_of_source source);
+
   (* Create a qcow2 v3 overlay to protect the source image(s).  There
    * is a specific reason to use the newer qcow2 variant: Because the
    * L2 table can store zero clusters efficiently, and because
-- 
1.9.0




More information about the Libguestfs mailing list