Extend open_guestfs to take an optional ?identifier parameter.
Use this parameter in virt-v2v which is currently the only place where
we use the handle identifier.
---
mllib/common_utils.ml | 3 ++-
mllib/common_utils.mli | 2 +-
v2v/output_rhev.ml | 3 +--
v2v/output_vdsm.ml | 3 +--
v2v/v2v.ml | 3 +--
v2v/windows.ml | 3 +--
6 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index 52079d2..13e9256 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -363,10 +363,11 @@ let info fs =
(* Common function to create a new Guestfs handle, with common options
* (e.g. debug, tracing) already set.
*)
-let open_guestfs () =
+let open_guestfs ?identifier () =
let g = new Guestfs.guestfs () in
if trace () then g#set_trace true;
if verbose () then g#set_verbose true;
+ may g#set_identifier identifier;
g
(* All the OCaml virt-* programs use this wrapper to catch exceptions
diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli
index d8f63d5..44b8c93 100644
--- a/mllib/common_utils.mli
+++ b/mllib/common_utils.mli
@@ -152,7 +152,7 @@ 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
+val open_guestfs : ?identifier:string -> unit -> Guestfs.guestfs
(** Common function to create a new Guestfs handle, with common options
(e.g. debug, tracing) already set. *)
diff --git a/v2v/output_rhev.ml b/v2v/output_rhev.ml
index 2878e13..2b8d989 100644
--- a/v2v/output_rhev.ml
+++ b/v2v/output_rhev.ml
@@ -262,8 +262,7 @@ object
?clustersize path format size =
Changeuid.func changeuid_t (
fun () ->
- let g = open_guestfs () in
- g#set_identifier "rhev_disk_create";
+ let g = open_guestfs ~identifier:"rhev_disk_create" () in
(* For qcow2, override v2v-supplied compat option, because RHEL 6
* nodes cannot handle qcow2 v3 (RHBZ#1145582).
*)
diff --git a/v2v/output_vdsm.ml b/v2v/output_vdsm.ml
index 079b47f..3c667f3 100644
--- a/v2v/output_vdsm.ml
+++ b/v2v/output_vdsm.ml
@@ -156,8 +156,7 @@ object
method disk_create ?backingfile ?backingformat ?preallocation ?compat
?clustersize path format size =
- let g = open_guestfs () in
- g#set_identifier "vdsm_disk_create";
+ let g = open_guestfs ~identifier:"vdsm_disk_create" () in
(* For qcow2, override v2v-supplied compat option, because RHEL 6
* nodes cannot handle qcow2 v3 (RHBZ#1145582).
*)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 7e8b459..f01a790 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -74,8 +74,7 @@ let rec main () =
| In_place -> message (f_"Opening the source VM")
);
- let g = open_guestfs () in
- g#set_identifier "v2v";
+ let g = open_guestfs ~identifier:"v2v" () in
g#set_network true;
(match conversion_mode with
| Copying (overlays, _) -> populate_overlays g overlays
diff --git a/v2v/windows.ml b/v2v/windows.ml
index d3bc5d9..b7447a5 100644
--- a/v2v/windows.ml
+++ b/v2v/windows.ml
@@ -72,8 +72,7 @@ let rec copy_virtio_drivers g inspect virtio_win driverdir =
)
else if is_regular_file virtio_win then (
try
- let g2 = open_guestfs () in
- g2#set_identifier "virtio_win";
+ let g2 = open_guestfs ~identifier:"virtio_win" () in
g2#add_drive_opts virtio_win ~readonly:true;
g2#launch ();
let vio_root = "/" in
--
2.5.0