[Libguestfs] [PATCH 06/10] builder: Use disk-create API instead of calling qemu-img create.

Richard W.M. Jones
2014-01-28T16:24:53Z

---
 builder/builder.ml | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/builder/builder.ml b/builder/builder.ml
index 3c45fa5..b01f4eb 100644
--- a/builder/builder.ml
+++ b/builder/builder.ml
@@ -513,14 +513,8 @@ let main ()        let { Index_parser.expand = expand;
lvexpand = lvexpand } = entry in
       msg (f_"Resizing (using virt-resize) to expand the disk to %s")
         (human_size osize);
-      let cmd -        sprintf "qemu-img create -f %s%s %s %Ld%s"
-          (quote oformat)
-          (if oformat = "qcow2" then " -o
preallocation=metadata" else "")
-          (quote ofile) osize
-          (if debug then "" else " >/dev/null
2>&1") in
-      if debug then eprintf "%s\n%!" cmd;
-      if Sys.command cmd <> 0 then exit 1;
+      let preallocation = if oformat = "qcow2" then Some
"metadata" else None in
+      (new G.guestfs ())#disk_create ?preallocation ofile oformat osize;
       let cmd          sprintf "virt-resize%s%s%s --output-format %s%s%s
%s %s"
           (if debug then " --verbose" else " --quiet")
--
1.8.4.2