This adds the -c option to the final qemu-img command.
(* Command line argument parsing. *)
let prog = Filename.basename Sys.executable_name
(* 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
let display_version () =
let g = new G.guestfs () in
let version = g#version () in
let add xs s = xs := s :: !xs in
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
let convert = ref "" in
let format = ref "" in
let ignores = ref [] in
let trace = ref false in
let argspec = Arg.align [
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";
"--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";
Arg.parse argspec anon_fun usage_msg;
(* Dereference the rest of the args. *)
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
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
if contains_comma then
error "input filename '%s' contains a comma; qemu-img command line syntax prevents us from using such an image" indisk;
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
let () =
if not quiet then
printf "Copy to destination and make sparse ...\n%!";
let cmd =
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)
(Filename.quote output_format)
+ (if compress then " -c" else "")
(Filename.quote overlaydisk) (Filename.quote outdisk) in
if verbose then
printf "%s\n%!" cmd;
(Filename.quote overlaydisk) (Filename.quote outdisk) in
if verbose then
printf "%s\n%!" cmd;
+=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
=item B<--convert> raw
=item B<--convert> qcow2
Specifying the I<--convert> option is usually a good idea, because
then virt-sparsify doesn't need to try to guess the input format.
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
=item B<--format> raw
=item B<--format> qcow2