[Libguestfs] [PATCH v2 14/17] v2v: factor out populating guestfs with overlays

Roman Kagan rkagan at virtuozzo.com
Tue Aug 11 17:00:33 UTC 2015


Signed-off-by: Roman Kagan <rkagan at virtuozzo.com>
---
 v2v/v2v.ml | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index e3a9cc1..1228316 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -851,6 +851,15 @@ let open_guestfs () =
   g#set_network true;
   g
 
+let 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
+
 let main () =
   (* Handle the command line. *)
   let input, output,
@@ -873,12 +882,7 @@ let main () =
 
   message (f_"Opening the overlay");
   let g = open_guestfs () in
-  List.iter (
-    fun ({ov_overlay_file = overlay_file}) ->
-      g#add_drive_opts overlay_file
-        ~format:"qcow2" ~cachemode:"unsafe" ~discard:"besteffort"
-        ~copyonread:true
-  ) overlays;
+  populate_overlays g overlays;
 
   g#launch ();
 
-- 
2.4.3




More information about the Libguestfs mailing list