X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=virt-p2v;h=e1ba0d13df3c40b40b0199d39dca02ee62baea48;hb=3eb1aa5b513f0ae2bad0ec7a62831714cdb17c14;hp=ad9e159bfdb8ddc0c7336bdd2ab4d97267326e5b;hpb=8bcc3e22f15e730841bddd4c8aaabbe910c473d3;p=virt-p2v.git diff --git a/virt-p2v b/virt-p2v index ad9e159..e1ba0d1 100755 --- a/virt-p2v +++ b/virt-p2v @@ -537,7 +537,8 @@ let rewrite_fstab state devices_to_send = fprintf chan "%-23s %-23s %-7s %-15s %s %s\n" dev mountpoint fstype options freq passno | line -> - output_string chan (String.concat " " line) + output_string chan (String.concat " " line); + output_char chan '\n' ) lines; close_out chan ) @@ -1475,25 +1476,26 @@ Compression: %b" let (sock,_) as conn = do_connect remote_name size in (* Copy the data. *) + let spinners = "|/-\\" (* "Oo" *) in let bufsize = 1024 * 1024 in let buffer = String.create bufsize in let start = gettimeofday () in - let rec copy bytes_sent last_printed_at = + let rec copy bytes_sent last_printed_at spinner = let n = read fd buffer 0 bufsize in if n > 0 then ( let n' = write sock buffer 0 n in if n <> n' then assert false; (* never, according to the manual *) let bytes_sent = Int64.add bytes_sent (Int64.of_int n) in - let last_printed_at = + let last_printed_at, spinner = let now = gettimeofday () in (* Print progress every few seconds. *) - if now -. last_printed_at > 5. then ( + if now -. last_printed_at > 2. then ( let elapsed = Int64.to_float bytes_sent /. Int64.to_float size in let secs_elapsed = now -. start in - printf "%.0f%% @ %.1f Mbps" - (100. *. elapsed) + printf "%.0f%% %c %.1f Mbps" + (100. *. elapsed) spinners.[spinner] (Int64.to_float bytes_sent/.secs_elapsed/.1_000_000. *. 8.); (* After 60 seconds has elapsed, start printing estimates. *) if secs_elapsed >= 60. then ( @@ -1506,14 +1508,15 @@ Compression: %b" secs_remaining ); printf " \r%!"; - now + let spinner = (spinner + 1) mod String.length spinners in + now, spinner ) - else last_printed_at in + else last_printed_at, spinner in - copy bytes_sent last_printed_at + copy bytes_sent last_printed_at spinner ) in - copy 0L start; + copy 0L start 0; printf "\n\n%!"; (* because of the messages printed above *) (* Disconnect. *)