summaryrefslogtreecommitdiffstats
path: root/sparsify
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-11-22 09:54:52 +0000
committerRichard W.M. Jones <rjones@redhat.com>2011-11-22 09:57:06 +0000
commitb83b705959c3c93bff0c343bcad09305399895a5 (patch)
tree44b8d993e5d290b3a95b9f81aaa0c7a68ebc911c /sparsify
parent342b4a55d056734a0344db8b4bcf1a90104a8a59 (diff)
downloadlibguestfs-b83b705959c3c93bff0c343bcad09305399895a5.tar.gz
libguestfs-b83b705959c3c93bff0c343bcad09305399895a5.tar.xz
libguestfs-b83b705959c3c93bff0c343bcad09305399895a5.zip
sparsify: Add --compress option.
This adds the -c option to the final qemu-img command.
Diffstat (limited to 'sparsify')
-rw-r--r--sparsify/sparsify.ml14
-rw-r--r--sparsify/virt-sparsify.pod7
2 files changed, 16 insertions, 5 deletions
diff --git a/sparsify/sparsify.ml b/sparsify/sparsify.ml
index 956fccbe..47dbbb95 100644
--- a/sparsify/sparsify.ml
+++ b/sparsify/sparsify.ml
@@ -28,8 +28,8 @@ let () = Random.self_init ()
(* Command line argument parsing. *)
let prog = Filename.basename Sys.executable_name
-let indisk, outdisk, convert, format, ignores, machine_readable, quiet,
- verbose, trace =
+let indisk, outdisk, compress, convert, format, ignores, machine_readable,
+ quiet, verbose, trace =
let display_version () =
let g = new G.guestfs () in
let version = g#version () in
@@ -40,6 +40,7 @@ let indisk, outdisk, convert, format, ignores, machine_readable, quiet,
let add xs s = xs := s :: !xs in
+ let compress = ref false in
let convert = ref "" in
let format = ref "" in
let ignores = ref [] in
@@ -49,6 +50,7 @@ let indisk, outdisk, convert, format, ignores, machine_readable, quiet,
let trace = ref false in
let argspec = Arg.align [
+ "--compress", Arg.Set compress, " Compressed output format";
"--convert", Arg.Set_string convert, "format Format of output disk (default: same as input)";
"--format", Arg.Set_string format, "format Format of input disk";
"--ignore", Arg.String (add ignores), "fs Ignore filesystem";
@@ -76,6 +78,7 @@ read the man page virt-sparsify(1).
Arg.parse argspec anon_fun usage_msg;
(* Dereference the rest of the args. *)
+ let compress = !compress in
let convert = match !convert with "" -> None | str -> Some str in
let format = match !format with "" -> None | str -> Some str in
let ignores = List.rev !ignores in
@@ -122,8 +125,8 @@ read the man page virt-sparsify(1).
if contains_comma then
error "input filename '%s' contains a comma; qemu-img command line syntax prevents us from using such an image" indisk;
- indisk, outdisk, convert, format, ignores, machine_readable, quiet,
- verbose, trace
+ indisk, outdisk, compress, convert, format, ignores, machine_readable,
+ quiet, verbose, trace
let () =
if not quiet then
@@ -287,8 +290,9 @@ let () =
printf "Copy to destination and make sparse ...\n%!";
let cmd =
- sprintf "qemu-img convert -f qcow2 -O %s %s %s"
+ sprintf "qemu-img convert -f qcow2 -O %s%s %s %s"
(Filename.quote output_format)
+ (if compress then " -c" else "")
(Filename.quote overlaydisk) (Filename.quote outdisk) in
if verbose then
printf "%s\n%!" cmd;
diff --git a/sparsify/virt-sparsify.pod b/sparsify/virt-sparsify.pod
index 77467b61..d25f013f 100644
--- a/sparsify/virt-sparsify.pod
+++ b/sparsify/virt-sparsify.pod
@@ -104,6 +104,11 @@ image.
Display help.
+=item B<--compress>
+
+Compress the output file. This I<only> works if the output format is
+C<qcow2>.
+
=item B<--convert> raw
=item B<--convert> qcow2
@@ -121,6 +126,8 @@ eg. C<vmdk>, but support for other formats is reliant on qemu.
Specifying the I<--convert> option is usually a good idea, because
then virt-sparsify doesn't need to try to guess the input format.
+For fine-tuning the output format, see: I<--compress>.
+
=item B<--format> raw
=item B<--format> qcow2