mllib, v2v: Allow open_guestfs to set the handle identifier.

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.
This commit is contained in:
Richard W.M. Jones
2015-11-10 20:10:44 +00:00
parent b91286c372
commit 905d98c127
6 changed files with 7 additions and 10 deletions

View File

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

View File

@@ -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. *)

View File

@@ -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).
*)

View File

@@ -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).
*)

View File

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

View File

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