git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
NEW API: add blkid command to print the attributes of the device
[libguestfs.git]
/
sparsify
/
sparsify.ml
diff --git
a/sparsify/sparsify.ml
b/sparsify/sparsify.ml
index
47dbbb9
..
dd3e043
100644
(file)
--- a/
sparsify/sparsify.ml
+++ b/
sparsify/sparsify.ml
@@
-28,8
+28,9
@@
let () = Random.self_init ()
(* 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, compress, convert, format, ignores, machine_readable,
- quiet, verbose, trace =
+let indisk, outdisk, compress, convert, debug_gc,
+ format, ignores, machine_readable,
+ option, 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
@@
-42,9
+43,11
@@
let indisk, outdisk, compress, convert, format, ignores, machine_readable,
let compress = ref false in
let convert = ref "" in
let compress = ref false in
let convert = ref "" in
+ let debug_gc = ref false in
let format = ref "" in
let ignores = ref [] in
let machine_readable = ref false in
let format = ref "" in
let ignores = ref [] in
let machine_readable = ref false in
+ let option = ref "" in
let quiet = ref false in
let verbose = ref false in
let trace = ref false in
let quiet = ref false in
let verbose = ref false in
let trace = ref false in
@@
-52,9
+55,11
@@
let indisk, outdisk, compress, convert, format, ignores, machine_readable,
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)";
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)";
+ "--debug-gc", Arg.Set debug_gc, " Debug GC and memory allocations";
"--format", Arg.Set_string format, "format Format of input disk";
"--ignore", Arg.String (add ignores), "fs Ignore filesystem";
"--machine-readable", Arg.Set machine_readable, " Make output machine readable";
"--format", Arg.Set_string format, "format Format of input disk";
"--ignore", Arg.String (add ignores), "fs Ignore filesystem";
"--machine-readable", Arg.Set machine_readable, " Make output machine readable";
+ "-o", Arg.Set_string option, "option Add qemu-img options";
"-q", Arg.Set quiet, " Quiet output";
"--quiet", Arg.Set quiet, " -\"-";
"-v", Arg.Set verbose, " Enable debugging messages";
"-q", Arg.Set quiet, " Quiet output";
"--quiet", Arg.Set quiet, " -\"-";
"-v", Arg.Set verbose, " Enable debugging messages";
@@
-80,9
+85,11
@@
read the man page virt-sparsify(1).
(* Dereference the rest of the args. *)
let compress = !compress in
let convert = match !convert with "" -> None | str -> Some str in
(* Dereference the rest of the args. *)
let compress = !compress in
let convert = match !convert with "" -> None | str -> Some str in
+ let debug_gc = !debug_gc in
let format = match !format with "" -> None | str -> Some str in
let ignores = List.rev !ignores in
let machine_readable = !machine_readable in
let format = match !format with "" -> None | str -> Some str in
let ignores = List.rev !ignores in
let machine_readable = !machine_readable in
+ let option = match !option with "" -> None | str -> Some str in
let quiet = !quiet in
let verbose = !verbose in
let trace = !trace in
let quiet = !quiet in
let verbose = !verbose in
let trace = !trace in
@@
-125,8
+132,9
@@
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;
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, compress, convert, format, ignores, machine_readable,
- quiet, verbose, trace
+ indisk, outdisk, compress, convert,
+ debug_gc, format, ignores, machine_readable,
+ option, quiet, verbose, trace
let () =
if not quiet then
let () =
if not quiet then
@@
-290,11
+298,14
@@
let () =
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 %s"
+ sprintf "qemu-img convert -f qcow2 -O %s%s
%s
%s %s"
(Filename.quote output_format)
(if compress then " -c" else "")
(Filename.quote output_format)
(if compress then " -c" else "")
+ (match option with
+ | None -> ""
+ | Some option -> " -o " ^ Filename.quote option)
(Filename.quote overlaydisk) (Filename.quote outdisk) in
(Filename.quote overlaydisk) (Filename.quote outdisk) in
- if verbose then
+(* if verbose then*)
printf "%s\n%!" cmd;
if Sys.command cmd <> 0 then
error "external command failed: %s" cmd
printf "%s\n%!" cmd;
if Sys.command cmd <> 0 then
error "external command failed: %s" cmd
@@
-306,4
+317,7
@@
let () =
wrap "Sparsify operation completed with no errors. Before deleting the old disk, carefully check that the target disk boots and works correctly.\n";
);
wrap "Sparsify operation completed with no errors. Before deleting the old disk, carefully check that the target disk boots and works correctly.\n";
);
+ if debug_gc then
+ Gc.compact ();
+
exit 0
exit 0