On Tue, Oct 20, 2015 at 04:08:18PM +0300, Roman Kagan wrote:
Signed-off-by: Roman Kagan <rkagan(a)virtuozzo.com>
---
v2v/v2v.ml | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index c28905d..23bd708 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -60,19 +60,9 @@ let rec main () =
let overlays = create_overlays source.s_disks in
let targets = init_targets overlays source output output_format in
- (* Open the guestfs handle. *)
message (f_"Opening the overlay");
- let g = new G.guestfs () in
- g#set_identifier "v2v";
- if trace () then g#set_trace true;
- if verbose () then g#set_verbose true;
- g#set_network true;
- List.iter (
- fun ({ov_overlay_file = overlay_file}) ->
- g#add_drive_opts overlay_file
- ~format:"qcow2" ~cachemode:"unsafe"
~discard:"besteffort"
- ~copyonread:true
- ) overlays;
+ let g = open_guestfs () in
+ populate_overlays g overlays;
g#launch ();
@@ -261,6 +251,24 @@ and init_targets overlays source output output_format =
output#prepare_targets source targets
+and open_guestfs () =
+ (* Open the guestfs handle. *)
+ let g = new G.guestfs () in
+ g#set_identifier "v2v";
+ if trace () then g#set_trace true;
+ if verbose () then g#set_verbose true;
+ g#set_network true;
+ g
+
+and populate_overlays (g:G.guestfs) overlays =
+ (* Populate guestfs handle with qcow2 overlays. *)
+ List.iter (
+ fun ({ov_overlay_file = overlay_file}) ->
+ g#add_drive_opts overlay_file
+ ~format:"qcow2" ~cachemode:"unsafe"
~discard:"besteffort"
+ ~copyonread:true
+ ) overlays
+
and inspect_source g root_choice =
let roots = g#inspect_os () in
let roots = Array.to_list roots in
ACK.
Since these are all the refactoring patches out of the way, I'm just
going to pause the review here, and test everything. If the tests
pass, I will push patches 1 - 10 immediately (except patch 9), and
then continue with the review.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html