[Pkg-libvirt-commits] [libguestfs] 14/17: sparsify: Use message function instead of printf.
Hilko Bengen
bengen at moszumanska.debian.org
Sun Nov 1 17:12:16 UTC 2015
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag upstream/1.29.43
in repository libguestfs.
commit ef4f0fc8f9f835179c25e9ae9762e9c9ebc6a958
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Fri May 15 20:22:05 2015 +0100
sparsify: Use message function instead of printf.
---
sparsify/copying.ml | 55 ++++++++++++++++++++--------------------------------
sparsify/in_place.ml | 17 +++++-----------
2 files changed, 26 insertions(+), 46 deletions(-)
diff --git a/sparsify/copying.ml b/sparsify/copying.ml
index 6b15471..80d7c9d 100644
--- a/sparsify/copying.ml
+++ b/sparsify/copying.ml
@@ -98,9 +98,9 @@ let run indisk outdisk check_tmpdir compress convert
| Directory tmpdir ->
(* Get virtual size of the input disk. *)
let virtual_size = (new G.guestfs ())#disk_virtual_size indisk in
- if not (quiet ()) then
- printf (f_"Input disk virtual size = %Ld bytes (%s)\n%!")
- virtual_size (human_size virtual_size);
+ if verbose () then
+ printf "input disk virtual size is %Ld bytes (%s)\n%!"
+ virtual_size (human_size virtual_size);
let print_warning () =
let free_space = statvfs_free_space tmpdir in
@@ -142,16 +142,13 @@ You can ignore this warning or change it to a hard failure using the
(* Create the temporary overlay file. *)
let overlaydisk =
- if not (quiet ()) then (
- match tmp_place with
- | Directory tmpdir ->
- printf (f_"Create overlay file in %s to protect source disk ...\n%!")
- tmpdir
- | Block_device device ->
- printf (f_"Create overlay device %s to protect source disk ...\n%!")
- device
- | Prebuilt_file file ->
- printf (f_"Using prebuilt file %s as overlay ...\n%!") file
+ (match tmp_place with
+ | Directory tmpdir ->
+ message (f_"Create overlay file in %s to protect source disk") tmpdir
+ | Block_device device ->
+ message (f_"Create overlay device %s to protect source disk") device
+ | Prebuilt_file file ->
+ message (f_"Using prebuilt file %s as overlay") file
);
(* Create 'tmp' with the indisk as the backing file. *)
@@ -179,8 +176,7 @@ You can ignore this warning or change it to a hard failure using the
(* Don't create anything, use the prebuilt file as overlay. *)
file in
- if not (quiet ()) then
- printf (f_"Examine source disk ...\n%!");
+ message (f_"Examine source disk");
(* Connect to libguestfs. *)
let g =
@@ -245,8 +241,7 @@ You can ignore this warning or change it to a hard failure using the
fun fs ->
if not (is_ignored fs) && not (is_read_only_lv fs) then (
if List.mem fs zeroes then (
- if not (quiet ()) then
- printf (f_"Zeroing %s ...\n%!") fs;
+ message (f_"Zeroing %s") fs;
g#zero_device fs
) else (
@@ -256,15 +251,11 @@ You can ignore this warning or change it to a hard failure using the
if mounted then (
if is_readonly_btrfs_snapshot fs "/" then (
- if not (quiet ()) then
- printf (f_"Skipping %s, as it is a read-only btrfs snapshot.\n%!") fs;
+ info (f_"Skipping %s, as it is a read-only btrfs snapshot.") fs;
) else if is_readonly_device "/" then (
- if not (quiet ()) then
- printf (f_"Skipping %s, as it is a read-only device.\n%!") fs;
+ info (f_"Skipping %s, as it is a read-only device.") fs;
) else (
- if not (quiet ()) then
- printf (f_"Fill free space in %s with zero ...\n%!") fs;
-
+ message (f_"Fill free space in %s with zero") fs;
g#zero_free_space "/"
)
) else (
@@ -279,8 +270,7 @@ You can ignore this warning or change it to a hard failure using the
with _ -> false in
if is_linux_x86_swap then (
- if not (quiet ()) then
- printf (f_"Clearing Linux swap on %s ...\n%!") fs;
+ message (f_"Clearing Linux swap on %s") fs;
(* Don't use mkswap. Just preserve the header containing
* the label, UUID and swap format version (libguestfs
@@ -313,8 +303,7 @@ You can ignore this warning or change it to a hard failure using the
with _ -> false in
if created then (
- if not (quiet ()) then
- printf (f_"Fill free space in volgroup %s with zero ...\n%!") vg;
+ message (f_"Fill free space in volgroup %s with zero") vg;
g#zero_device lvdev;
g#sync ();
@@ -334,8 +323,7 @@ You can ignore this warning or change it to a hard failure using the
(* Now run qemu-img convert which copies the overlay to the
* destination and automatically does sparsification.
*)
- if not (quiet ()) then
- printf (f_"Copy to destination and make sparse ...\n%!");
+ message ("Copy to destination and make sparse");
let cmd =
sprintf "qemu-img convert -f qcow2 -O %s%s%s %s %s"
@@ -351,7 +339,6 @@ You can ignore this warning or change it to a hard failure using the
error (f_"external command failed: %s") cmd;
(* Finished. *)
- if not (quiet ()) then (
- print_newline ();
- wrap (s_"Sparsify operation completed with no errors. Before deleting the old disk, carefully check that the target disk boots and works correctly.\n");
- )
+ message (f_"Sparsify operation completed with no errors.");
+ if not (quiet ()) then
+ info (f_"Before deleting the old disk, carefully check that the target disk boots and works correctly.")
diff --git a/sparsify/in_place.ml b/sparsify/in_place.ml
index 0a62a3d..131f8b1 100644
--- a/sparsify/in_place.ml
+++ b/sparsify/in_place.ml
@@ -75,8 +75,7 @@ and perform g disk format ignores machine_readable zeroes =
fun fs ->
if not (is_ignored fs) && not (is_read_only_lv fs) then (
if List.mem fs zeroes then (
- if not (quiet ()) then
- printf (f_"Zeroing %s ...\n%!") fs;
+ message (f_"Zeroing %s") fs;
if not (g#blkdiscardzeroes fs) then
g#zero_device fs;
@@ -87,8 +86,7 @@ and perform g disk format ignores machine_readable zeroes =
with _ -> false in
if mounted then (
- if not (quiet ()) then
- printf (f_"Trimming %s ...\n%!") fs;
+ message (f_"Trimming %s") fs;
g#fstrim "/"
) else (
@@ -103,8 +101,7 @@ and perform g disk format ignores machine_readable zeroes =
with _ -> false in
if is_linux_x86_swap then (
- if not (quiet ()) then
- printf (f_"Clearing Linux swap on %s ...\n%!") fs;
+ message (f_"Clearing Linux swap on %s") fs;
(* Don't use mkswap. Just preserve the header containing
* the label, UUID and swap format version (libguestfs
@@ -137,8 +134,7 @@ and perform g disk format ignores machine_readable zeroes =
with _ -> false in
if created then (
- if not (quiet ()) then
- printf (f_"Discard space in volgroup %s ...\n%!") vg;
+ message (f_"Discard space in volgroup %s") vg;
g#blkdiscard lvdev;
g#sync ();
@@ -151,7 +147,4 @@ and perform g disk format ignores machine_readable zeroes =
g#close ();
(* Finished. *)
- if not (quiet ()) then (
- print_newline ();
- wrap (s_"Sparsify in-place operation completed with no errors.\n");
- )
+ message (f_"Sparsify in-place operation completed with no errors")
--
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