[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 1/4] v2v: Pass output object into the conversion module.



Previously the Convert_linux conversion module depended on one feature
of the output module (#keep_serial_console).  This was extracted in an
ad-hoc way from the output module and passed as an extra parameter to
the conversion module.

Instead of doing it this way, just pass the output module into the
conversion module, so it can call output#keep_serial_console itself.

This is just a simplification of the existing code, but otherwise adds
no new features.
---
 v2v/convert_linux.ml   | 4 ++--
 v2v/convert_windows.ml | 2 +-
 v2v/modules_list.ml    | 5 +++--
 v2v/modules_list.mli   | 7 ++++---
 v2v/v2v.ml             | 7 +++----
 5 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
index 7c42791..7d65516 100644
--- a/v2v/convert_linux.ml
+++ b/v2v/convert_linux.ml
@@ -38,7 +38,7 @@ open Linux_kernels
 module G = Guestfs
 
 (* The conversion function. *)
-let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps =
+let rec convert (g : G.guestfs) inspect source output rcaps =
   (*----------------------------------------------------------------------*)
   (* Inspect the guest first.  We already did some basic inspection in
    * the common v2v.ml code, but that has to deal with generic guests
@@ -1005,7 +1005,7 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps =
 
   let kernel, virtio = configure_kernel () in
 
-  if keep_serial_console then (
+  if output#keep_serial_console then (
     configure_console ();
     bootloader#configure_console ();
   ) else (
diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml
index e259c22..36f47c8 100644
--- a/v2v/convert_windows.ml
+++ b/v2v/convert_windows.ml
@@ -37,7 +37,7 @@ module G = Guestfs
  * time the Windows VM is booted on KVM.
  *)
 
-let convert ~keep_serial_console (g : G.guestfs) inspect source rcaps =
+let convert (g : G.guestfs) inspect source output rcaps =
   (* Get the data directory. *)
   let virt_tools_data_dir =
     try Sys.getenv "VIRT_TOOLS_DATA_DIR"
diff --git a/v2v/modules_list.ml b/v2v/modules_list.ml
index 13dfee2..3b3cf2e 100644
--- a/v2v/modules_list.ml
+++ b/v2v/modules_list.ml
@@ -27,9 +27,10 @@ and register_output_module name = push_front name output_modules
 let input_modules () = List.sort compare !input_modules
 and output_modules () = List.sort compare !output_modules
 
+type inspection_fn = Types.inspect -> bool
+
 type conversion_fn =
-  keep_serial_console:bool ->
-  Guestfs.guestfs -> Types.inspect -> Types.source ->
+  Guestfs.guestfs -> Types.inspect -> Types.source -> Types.output ->
   Types.requested_guestcaps -> Types.guestcaps
 
 let convert_modules = ref []
diff --git a/v2v/modules_list.mli b/v2v/modules_list.mli
index 5db9227..100c54e 100644
--- a/v2v/modules_list.mli
+++ b/v2v/modules_list.mli
@@ -30,12 +30,13 @@ val input_modules : unit -> string list
 val output_modules : unit -> string list
 (** Return the list of output modules. *)
 
+type inspection_fn = Types.inspect -> bool
+
 type conversion_fn =
-  keep_serial_console:bool ->
-  Guestfs.guestfs -> Types.inspect -> Types.source ->
+  Guestfs.guestfs -> Types.inspect -> Types.source -> Types.output ->
   Types.requested_guestcaps -> Types.guestcaps
 
-val register_convert_module : (Types.inspect -> bool) -> string -> conversion_fn -> unit
+val register_convert_module : inspection_fn -> string -> conversion_fn -> unit
 (** [register_convert_module inspect_fn name fn] registers a
     conversion function [fn] that can accept any guest that matches
     the [inspect_fn] function. *)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index ee00d2e..b9fb759 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -103,7 +103,6 @@ let rec main () =
 
   (* Conversion. *)
   let guestcaps =
-    let keep_serial_console = output#keep_serial_console in
     let rcaps =
       match conversion_mode with
       | Copying _ ->
@@ -111,7 +110,7 @@ let rec main () =
       | In_place ->
          rcaps_from_source source in
 
-    do_convert g inspect source keep_serial_console rcaps in
+    do_convert g inspect source output rcaps in
 
   g#umount_all ();
 
@@ -549,7 +548,7 @@ and check_target_free_space mpstats source targets output =
   output#check_target_free_space source targets
 
 (* Conversion. *)
-and do_convert g inspect source keep_serial_console rcaps =
+and do_convert g inspect source output rcaps =
   (match inspect.i_product_name with
   | "unknown" ->
     message (f_"Converting the guest to run on KVM")
@@ -564,7 +563,7 @@ and do_convert g inspect source keep_serial_console rcaps =
         inspect.i_type inspect.i_distro in
   debug "picked conversion module %s" conversion_name;
   debug "requested caps: %s" (string_of_requested_guestcaps rcaps);
-  let guestcaps = convert ~keep_serial_console g inspect source rcaps in
+  let guestcaps = convert g inspect source output rcaps in
   debug "%s" (string_of_guestcaps guestcaps);
 
   (* Did we manage to install virtio drivers? *)
-- 
2.9.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]