On Mon, 6 Feb 2017 15:40:01 +0000 "Richard W.M. Jones" <rjones@redhat.com> wrote:
+let qemu_img_supports_offset_and_size () = + (* We actually attempt to create a qcow2 file with a raw backing + * file that has an offset and size. + *) + let tmp1 = Filename.temp_file "v2vqemuimgtst" ".img" + and tmp2 = Filename.temp_file "v2vqemuimgtst" ".img" in + Unix.truncate tmp2 1024; + + let json = [ + "file", JSON.Dict [ + "driver", JSON.String "raw"; + "offset", JSON.Int 512; + "size", JSON.Int 512; + "file", JSON.Dict [ + "filename", JSON.String tmp2 + ] + ] + ] in + + let cmd = + sprintf "qemu-img create %s -f qcow2 -b 'json:%s'%s" + (quote tmp1) + (quote (JSON.string_of_doc ~fmt:JSON.Compact json)) + (if verbose () then "" else " >/dev/null 2>&1") in + + let r = Sys.command cmd in + + Unix.unlink tmp1; + Unix.unlink tmp2; +
LGTM. But you can avoid the temporary files as I mentioned here: https://www.redhat.com/archives/libguestfs/2017-February/msg00079.html Tomas -- Tomáš Golembiovský <tgolembi@redhat.com>