diff options
| author | Richard W.M. Jones <rjones@redhat.com> | 2012-09-03 16:46:10 +0100 |
|---|---|---|
| committer | Richard W.M. Jones <rjones@redhat.com> | 2012-09-03 17:45:14 +0100 |
| commit | faaedeb3432253847107ca2c4530f681c6a1e385 (patch) | |
| tree | 2824670970a3fd6e7ec199378b4a0234a0efb2b9 /sparsify | |
| parent | 9f8ba4e8d16e5c50c3cd657f9beae3518947b6ed (diff) | |
| download | libguestfs-faaedeb3432253847107ca2c4530f681c6a1e385.tar.gz libguestfs-faaedeb3432253847107ca2c4530f681c6a1e385.tar.xz libguestfs-faaedeb3432253847107ca2c4530f681c6a1e385.zip | |
sparsify: Use guestfs_disk_format to autodetect input format (RHBZ#853762).
Diffstat (limited to 'sparsify')
| -rw-r--r-- | sparsify/sparsify.ml | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/sparsify/sparsify.ml b/sparsify/sparsify.ml index 379ccf48..fa729f36 100644 --- a/sparsify/sparsify.ml +++ b/sparsify/sparsify.ml @@ -351,25 +351,10 @@ let output_format = | Some fmt -> fmt (* user specified input format, use that *) | None -> (* Don't know, so we must autodetect. *) - let cmd = sprintf "file -bsL %s" (Filename.quote indisk) in - let chan = open_process_in cmd in - let line = input_line chan in - let stat = close_process_in chan in - (match stat with - | WEXITED 0 -> () - | WEXITED _ -> - error (f_"external command failed: %s") cmd - | WSIGNALED i -> - error (f_"external command '%s' killed by signal %d") cmd i - | WSTOPPED i -> - error (f_"external command '%s' stopped by signal %d") cmd i - ); - if string_prefix line "QEMU QCOW Image (v2)" then - "qcow2" - else if string_find line "VirtualBox" >= 0 then - "vdi" - else - "raw" (* XXX guess *) + match g#disk_format indisk with + | "unknown" -> + error (f_"cannot detect input disk format; use the --format parameter") + | fmt -> fmt (* Now run qemu-img convert which copies the overlay to the * destination and automatically does sparsification. |
