[Pkg-libvirt-commits] [libguestfs] 85/266: v2v: Nothing uses ov_target_file_tmp, remove this.

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:41:45 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.27.35-1
in repository libguestfs.

commit bfcda1ba6a21906d2f82c19cf43bcd475bb4f5d8
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Tue Aug 12 17:44:51 2014 +0100

    v2v: Nothing uses ov_target_file_tmp, remove this.
    
    Previous virt-v2v would write to a temporary destination file then
    atomically rename everything at the end.
    
    However this appears to be unnecessary since we write the OVF file
    after copying the disks, so (I assume) RHEV-M won't see the disks
    before then.
    
    In any case nothing used ov_target_file_tmp so we can remove this
    feature to simplify the code.
---
 v2v/target_RHEV.ml  |  3 +--
 v2v/target_local.ml |  2 +-
 v2v/types.ml        |  4 +---
 v2v/types.mli       |  3 +--
 v2v/v2v.ml          | 18 +++++-------------
 5 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/v2v/target_RHEV.ml b/v2v/target_RHEV.ml
index d2f3846..77d0bf8 100644
--- a/v2v/target_RHEV.ml
+++ b/v2v/target_RHEV.ml
@@ -158,8 +158,7 @@ let rec initialize ~verbose os rhev_params source output_alloc overlays =
         fpf "EOF\n";
         close_out chan;
 
-        { ov with
-          ov_target_file_tmp = target_file; ov_target_file = target_file }
+        { ov with ov_target_file = target_file }
     ) overlays in
 
   (* Return the list of overlays. *)
diff --git a/v2v/target_local.ml b/v2v/target_local.ml
index b37b6fa..e017d8a 100644
--- a/v2v/target_local.ml
+++ b/v2v/target_local.ml
@@ -28,7 +28,7 @@ let initialize dir source overlays =
   List.map (
     fun ov ->
       let target_file = dir // source.s_name ^ "-" ^ ov.ov_sd in
-      { ov with ov_target_file = target_file; ov_target_file_tmp = target_file }
+      { ov with ov_target_file = target_file }
   ) overlays
 
 let create_metadata dir source overlays guestcaps =
diff --git a/v2v/types.ml b/v2v/types.ml
index 0231c66..9f8a71f 100644
--- a/v2v/types.ml
+++ b/v2v/types.ml
@@ -83,7 +83,6 @@ and string_of_source_disk { s_qemu_uri = qemu_uri; s_format = format;
 type overlay = {
   ov_overlay : string;
   ov_target_file : string;
-  ov_target_file_tmp : string;
   ov_target_format : string;
   ov_sd : string;
   ov_virtual_size : int64;
@@ -97,7 +96,6 @@ let string_of_overlay ov =
   sprintf "\
 ov_overlay = %s
 ov_target_file = %s
-ov_target_file_tmp = %s
 ov_target_format = %s
 ov_sd = %s
 ov_virtual_size = %Ld
@@ -107,7 +105,7 @@ ov_source_format = %s
 ov_vol_uuid = %s
 "
     ov.ov_overlay
-    ov.ov_target_file ov.ov_target_file_tmp
+    ov.ov_target_file
     ov.ov_target_format
     ov.ov_sd
     ov.ov_virtual_size
diff --git a/v2v/types.mli b/v2v/types.mli
index 433aa06..7479ca0 100644
--- a/v2v/types.mli
+++ b/v2v/types.mli
@@ -60,8 +60,7 @@ val string_of_source_disk : source_disk -> string
 
 type overlay = {
   ov_overlay : string;       (** Local overlay file (qcow2 format). *)
-  ov_target_file : string;   (** Destination file (real). *)
-  ov_target_file_tmp : string;    (** Destination file (temporary). *)
+  ov_target_file : string;   (** Destination file. *)
   ov_target_format : string; (** Destination format (eg. -of option). *)
   ov_sd : string;            (** sdX libguestfs name of disk. *)
   ov_virtual_size : int64;   (** Virtual disk size in bytes. *)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 9989643..652d514 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -154,7 +154,7 @@ let rec main () =
   at_exit (fun () ->
     if !delete_target_on_exit then (
       List.iter (
-        fun ov -> try Unix.unlink ov.ov_target_file_tmp with _ -> ()
+        fun ov -> try Unix.unlink ov.ov_target_file with _ -> ()
       ) overlays
     )
   );
@@ -173,13 +173,13 @@ let rec main () =
       let preallocation = ov.ov_preallocation in
       let compat =
         match ov.ov_target_format with "qcow2" -> Some "1.1" | _ -> None in
-      (new G.guestfs ())#disk_create ov.ov_target_file_tmp
+      (new G.guestfs ())#disk_create ov.ov_target_file
         ov.ov_target_format ov.ov_virtual_size ?preallocation ?compat;
 
       let cmd =
         sprintf "qemu-img convert -n -f qcow2 -O %s %s %s"
           (quote ov.ov_target_format) (quote ov.ov_overlay)
-          (quote ov.ov_target_file_tmp) in
+          (quote ov.ov_target_file) in
       if verbose then printf "%s\n%!" cmd;
       if Sys.command cmd <> 0 then
         error (f_"qemu-img command failed, see earlier errors");
@@ -201,16 +201,8 @@ let rec main () =
       Target_RHEV.create_metadata os rhev_params renamed_source output_alloc
         overlays inspect guestcaps in
 
-  (* If we wrote to a temporary file, rename to the real file. *)
-  List.iter (
-    fun ov ->
-      if ov.ov_target_file_tmp <> ov.ov_target_file then
-        rename ov.ov_target_file_tmp ov.ov_target_file
-  ) overlays;
-
-  delete_target_on_exit := false;
-
   msg (f_"Finishing off");
+  delete_target_on_exit := false;  (* Don't delete target on exit. *)
 
   if debug_gc then
     Gc.compact ()
@@ -243,7 +235,7 @@ and initialize_target ~verbose g
           | _ -> None (* ignore -oa flag for other formats *) in
 
         { ov_overlay = overlay;
-          ov_target_file = ""; ov_target_file_tmp = "";
+          ov_target_file = "";
           ov_target_format = format;
           ov_sd = sd; ov_virtual_size = vsize; ov_preallocation = preallocation;
           ov_source_file = qemu_uri; ov_source_format = backing_format;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list