[Libguestfs] [PATCH 07/14] v2v: In -o local mode, name disks <name>-sda instead of disk-sda.

Richard W.M. Jones rjones at redhat.com
Mon Jun 23 11:32:23 UTC 2014


This allows us to use the same shared output directory for multiple
parallel tests.
---
 v2v/target_local.ml  |  4 ++--
 v2v/target_local.mli |  2 +-
 v2v/v2v.ml           | 12 +++++++++---
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/v2v/target_local.ml b/v2v/target_local.ml
index ed4e5e3..b37b6fa 100644
--- a/v2v/target_local.ml
+++ b/v2v/target_local.ml
@@ -24,10 +24,10 @@ open Common_utils
 open Types
 open Utils
 
-let initialize dir overlays =
+let initialize dir source overlays =
   List.map (
     fun ov ->
-      let target_file = dir // "disk-" ^ ov.ov_sd in
+      let target_file = dir // source.s_name ^ "-" ^ ov.ov_sd in
       { ov with ov_target_file = target_file; ov_target_file_tmp = target_file }
   ) overlays
 
diff --git a/v2v/target_local.mli b/v2v/target_local.mli
index 1833ecb..4907ac1 100644
--- a/v2v/target_local.mli
+++ b/v2v/target_local.mli
@@ -16,6 +16,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *)
 
-val initialize : string -> Types.overlay list -> Types.overlay list
+val initialize : string -> Types.source -> Types.overlay list -> Types.overlay list
 
 val create_metadata : string -> Types.source -> Types.overlay list -> Types.guestcaps -> unit
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 838354f..f7d29a3 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -93,7 +93,8 @@ let rec main () =
    * work.
    *)
   let overlays =
-    initialize_target g output output_alloc output_format overlays in
+    initialize_target g
+      source output output_alloc output_format output_name overlays in
 
   (* Inspection - this also mounts up the filesystems. *)
   msg (f_"Inspecting the overlay");
@@ -214,7 +215,8 @@ let rec main () =
   if debug_gc then
     Gc.compact ()
 
-and initialize_target g output output_alloc output_format overlays =
+and initialize_target g
+    source output output_alloc output_format output_name overlays =
   let overlays =
     mapi (
       fun i (overlay, qemu_uri, backing_format) ->
@@ -247,9 +249,13 @@ and initialize_target g output output_alloc output_format overlays =
           ov_source_file = qemu_uri; ov_source_format = backing_format; }
     ) overlays in
   let overlays =
+    let renamed_source =
+      match output_name with
+      | None -> source
+      | Some name -> { source with s_name = name } in
     match output with
     | OutputLibvirt oc -> assert false
-    | OutputLocal dir -> Target_local.initialize dir overlays
+    | OutputLocal dir -> Target_local.initialize dir renamed_source overlays
     | OutputRHEV os -> assert false in
   overlays
 
-- 
1.9.0




More information about the Libguestfs mailing list