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

[Libguestfs] [PATCH 2/7] v2v: Move the open_guestfs function into Common_utils.



Removes the somewhat ugly inclusion of this function in Types.  Also
means we can use this function elsewhere.
---
 mllib/common_utils.ml  | 9 +++++++++
 mllib/common_utils.mli | 4 ++++
 v2v/types.ml           | 7 -------
 v2v/types.mli          | 5 -----
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index d444855..d654fa8 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -356,6 +356,15 @@ let info fs =
   in
   ksprintf display fs
 
+(* Common function to create a new Guestfs handle, with common options
+ * (e.g. debug, tracing) already set.
+ *)
+let open_guestfs () =
+  let g = new Guestfs.guestfs () in
+  if trace () then g#set_trace true;
+  if verbose () then g#set_verbose true;
+  g
+
 (* All the OCaml virt-* programs use this wrapper to catch exceptions
  * and print them nicely.
  *)
diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli
index 473efb9..6e08e43 100644
--- a/mllib/common_utils.mli
+++ b/mllib/common_utils.mli
@@ -149,6 +149,10 @@ val warning : ('a, unit, string, unit) format4 -> 'a
 val info : ('a, unit, string, unit) format4 -> 'a
 (** Standard info function.  Note: Use full sentences for this. *)
 
+val open_guestfs : unit -> Guestfs.guestfs
+(** Common function to create a new Guestfs handle, with common options
+    (e.g. debug, tracing) already set. *)
+
 val run_main_and_handle_errors : (unit -> unit) -> unit
 (** Common function for handling pretty-printing exceptions. *)
 
diff --git a/v2v/types.ml b/v2v/types.ml
index 038d259..7118fad 100644
--- a/v2v/types.ml
+++ b/v2v/types.ml
@@ -382,13 +382,6 @@ let string_of_target_buses buses =
   string_of_target_bus_slots "ide" buses.target_ide_bus ^
   string_of_target_bus_slots "scsi" buses.target_scsi_bus
 
-let open_guestfs () =
-  (* Open the guestfs handle. *)
-  let g = new Guestfs.guestfs () in
-  if trace () then g#set_trace true;
-  if verbose () then g#set_verbose true;
-  g
-
 class virtual input = object
   method virtual as_options : string
   method virtual source : unit -> source
diff --git a/v2v/types.mli b/v2v/types.mli
index 9e8932e..55fb09a 100644
--- a/v2v/types.mli
+++ b/v2v/types.mli
@@ -253,8 +253,3 @@ type output_allocation = Sparse | Preallocated
 
 type vmtype = Desktop | Server
 (** Type of [--vmtype] option. *)
-
-val open_guestfs : unit -> Guestfs.guestfs
-(* Create a new Guestfs handle, with common options (e.g. debug, tracing)
- * already set.
- *)
-- 
2.5.0


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