[Pkg-libvirt-commits] [libguestfs] 173/266: v2v: Inline the initialize_target function.

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:41:58 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.35-1
in repository libguestfs.

commit 862a27c92d495975cc12925599333e108f16b20d
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Mon Aug 25 20:29:31 2014 +0100

    v2v: Inline the initialize_target function.
    
    This function had got smaller and smaller until now we might as well
    just inline it.  Having it after the main function just obscured the
    order that the code runs.
    
    No functional change, just refactoring.
---
 v2v/v2v.ml | 48 +++++++++++++++++++-----------------------------
 1 file changed, 19 insertions(+), 29 deletions(-)

diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 74295fc..cdd1e35 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -132,8 +132,25 @@ let rec main () =
    *)
   msg (f_"Initializing the target %s") output#as_options;
   let overlays =
-    initialize_target ~verbose g
-      source output output_format output_name overlays in
+    mapi (
+      fun i (overlay, qemu_uri, backing_format) ->
+        (* Grab the virtual size of each disk. *)
+        let sd = "sd" ^ drive_name i in
+        let dev = "/dev/" ^ sd in
+        let vsize = g#blockdev_getsize64 dev in
+
+        (* What output format should we use? *)
+        let format =
+          match output_format, backing_format with
+          | Some format, _ -> format    (* -of overrides everything *)
+          | None, Some format -> format (* same as backing format *)
+          | None, None ->
+            error (f_"disk %s (%s) has no defined format, you have to either define the original format in the source metadata, or use the '-of' option to force the output format") sd qemu_uri in
+
+        { ov_overlay = overlay; ov_target_file = ""; ov_target_format = format;
+          ov_sd = sd; ov_virtual_size = vsize; ov_source_file = qemu_uri }
+    ) overlays in
+  let overlays = output#prepare_output source overlays in
 
   (* Inspection - this also mounts up the filesystems. *)
   msg (f_"Inspecting the overlay");
@@ -242,33 +259,6 @@ let rec main () =
   if debug_gc then
     Gc.compact ()
 
-and initialize_target ~verbose g
-    source output output_format output_name overlays =
-  let overlays =
-    mapi (
-      fun i (overlay, qemu_uri, backing_format) ->
-        (* Grab the virtual size of each disk. *)
-        let sd = "sd" ^ drive_name i in
-        let dev = "/dev/" ^ sd in
-        let vsize = g#blockdev_getsize64 dev in
-
-        (* What output format should we use? *)
-        let format =
-          match output_format, backing_format with
-          | Some format, _ -> format    (* -of overrides everything *)
-          | None, Some format -> format (* same as backing format *)
-          | None, None ->
-            error (f_"disk %s (%s) has no defined format, you have to either define the original format in the source metadata, or use the '-of' option to force the output format") sd qemu_uri in
-
-        { ov_overlay = overlay;
-          ov_target_file = "";
-          ov_target_format = format;
-          ov_sd = sd; ov_virtual_size = vsize;
-          ov_source_file = qemu_uri }
-    ) overlays in
-  let overlays = output#prepare_output source overlays in
-  overlays
-
 and inspect_source g root_choice =
   let roots = g#inspect_os () in
   let roots = Array.to_list roots in

-- 
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