search for: detect_file_type

Displaying 20 results from an estimated 57 matches for "detect_file_type".

2017 Mar 13
0
[PATCH 1/2] v2v: -i ova: Hoist utility functions to the top of the file.
...open_process_full cmd [||] in + let b = Bytes.create 512 in + let len = input chan_out b 0 (Bytes.length b) in + (* We're expecting the subprocess to fail because we close + * the pipe early, so: + *) + ignore (Unix.close_process_full (chan_out, chan_in, chan_err)); + b, len + +(* Run [detect_file_type] on a compressed file, returning the + * type of the uncompressed content (if known). + *) +let uncompressed_type format file = + let zcat = match format with `GZip -> "zcat" | `XZ -> "xzcat" in + let head, headlen = uncompress_head zcat file in + let tmpfile, chan = +...
2015 Mar 05
0
[PATCH v2] customize: add --truncate-recursive option
...truncate_recursive (g : Guestfs.guestfs) dir = + if g#is_dir dir then ( + let files = Array.map (Filename.concat dir) (g#find dir) in + let files = Array.to_list files in + let files = List.filter g#is_file files in + List.iter g#truncate files + ) + (* Detect type of a file. *) let detect_file_type filename = let chan = open_in filename in diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli index 28ba648..15bd54e 100644 --- a/mllib/common_utils.mli +++ b/mllib/common_utils.mli @@ -129,6 +129,8 @@ val rm_rf_only_files : Guestfs.guestfs -> string -> unit XXX Could be fa...
2015 Mar 05
2
[PATCH v2] customize: add --truncate-recursive option
Allows user to recursively truncate all files in a directory. Related to RHBZ#119673 Maros Zatko (1): customize: add --truncate-recursive option builder/cmdline.ml | 3 ++- customize/customize_run.ml | 4 ++++ generator/customize.ml | 8 ++++++++ mllib/common_utils.ml | 8 ++++++++ mllib/common_utils.mli | 2 ++ 5 files changed, 24 insertions(+), 1 deletion(-) -- 1.9.3
2017 Feb 06
3
[PATCH] v2v: ova: Don't rely on qemu-img version, test "offset" and
Not tested yet, am running the tests now. Rich.
2014 Oct 18
5
GIT: [PATCH 0/5] v2v: Multiple fixes for handling semi-standard OVA files (RHBZ#1152998).
OVA not a real standard. Colour me surprised ...
2017 Mar 13
4
[PATCH 0/2] v2v: -i ova: A couple of cleanup patches.
A couple of patches cleaning up the -i ova code. These are both just refactoring (or should be at any rate). The second patch is best viewed with 'git show -w' to exclude whitespace changes. Rich.
2016 Jun 13
1
[PATCH] customize: Give an error if --truncate-recursive path does not exist (RHBZ#1345809).
...- let files = List.filter g#is_file files in - List.iter g#truncate files - ) + let files = Array.map (Filename.concat dir) (g#find dir) in + let files = Array.to_list files in + let files = List.filter g#is_file files in + List.iter g#truncate files (* Detect type of a file. *) let detect_file_type filename = -- 2.7.4
2016 Nov 04
0
[PATCH 3/5] v2v: ova: move the untar function
...?(format = "") file outdir = - let cmd = [ "tar"; sprintf "-x%sf" format; file; "-C"; outdir ] in - if run_command cmd <> 0 then - error (f_"error unpacking %s, see earlier error messages") ova in - match detect_file_type ova with | `Tar -> (* Normal ovas are tar file (not compressed). *) -- 2.10.1
2016 Dec 07
0
[PATCH v3 3/6] v2v: ova: move the untar function
...?(format = "") file outdir = - let cmd = [ "tar"; sprintf "-x%sf" format; file; "-C"; outdir ] in - if run_command cmd <> 0 then - error (f_"error unpacking %s, see earlier error messages") ova in - match detect_file_type ova with | `Tar -> (* Normal ovas are tar file (not compressed). *) -- 2.10.2
2016 Dec 07
0
[PATCH v3 2/6] v2v: ova: don't detect compressed disks, read the OVF instead
...et filename = ovf_folder // filename in Unix.access filename [Unix.R_OK]; @@ -282,17 +289,16 @@ object (* The spec allows the file to be gzip-compressed, in which case * we must uncompress it into the tmpdir. *) - let filename = - if detect_file_type filename = `GZip then ( - let new_filename = tmpdir // String.random8 () ^ ".vmdk" in - let cmd = - sprintf "zcat %s > %s" (quote filename) (quote new_filename) in - if shell_command cmd <> 0 then - er...
2016 Nov 12
0
[PATCH v2 2/5] v2v: ova: don't detect compressed disks, read the OVF instead
...t readable? *) - let filename = ovf_folder // filename in Unix.access filename [Unix.R_OK]; - (* The spec allows the file to be gzip-compressed, in which case - * we must uncompress it into the tmpdir. - *) - let filename = - if detect_file_type filename = `GZip then ( - let new_filename = tmpdir // String.random8 () ^ ".vmdk" in - let cmd = - sprintf "zcat %s > %s" (quote filename) (quote new_filename) in - if shell_command cmd <> 0 then - er...
2017 Feb 06
0
[PATCH] v2v: ova: Don't rely on qemu-img version, test "offset" and "size" features.
...++++++++++++++++++++++++++++++-------------------- v2v/utils.mli | 7 +++---- 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml index 3c11cd0..3beaffc 100644 --- a/v2v/input_ova.ml +++ b/v2v/input_ova.ml @@ -90,9 +90,8 @@ object match detect_file_type ova with | `Tar -> (* Normal ovas are tar file (not compressed). *) - let qmajor, qminor = qemu_img_version () in - if qmajor > 2 || (qmajor == 2 && qminor >= 8) then ( - (* If QEMU is 2.8 or newer we don't have to extract everyt...
2020 Apr 06
0
[v2v PATCH 2/2] Consolidate handling of temporary files/dirs
...dir = - let base_dir = (open_guestfs ())#get_cachedir () in - let t = Mkdtemp.temp_dir ~base_dir "ova." in - rmdir_on_exit t; - t in + let ovatmpdir = + let d = cachedir // "ova" in + Unix.mkdir d 0o700; + d in match detect_file_type ova with | `Tar -> @@ -85,15 +84,15 @@ let rec parse_ova ova = *) if qemu_img_supports_offset_and_size () && libvirt_supports_json_raw_driver () && - (untar_metadata ova tmpdir; - no_disks_are_compressed ova tmpdir)...
2017 Nov 21
0
[PATCH v13 2/3] builder: add a template parameter to get_index
...oc ("format", None) fields) with Not_found -> None in let size = + let get_image_size filepath = + (* If a compressed image manages to reach this code, qemu-img just + returns a virtual-size equal to actual-size *) + match detect_file_type filepath with + | `Unknown -> + let infos = Utils.get_image_infos filepath in + Yajl.object_get_number "virtual-size" infos + | `XZ | `GZip | `Tar | ` Zip -> + eprintf (f_"%s: cannot determine the virtal siz...
2017 Feb 06
2
[PATCH v2] v2v: ova: Don't rely on qemu-img version, test "offset"
v1 -> v2: - Use 'qemu-img info' which avoids one of the temporary files (thanks Tomáš). - Add a unit test. Unfortunately when I run 'make -C v2v check' I don't think this code is being run at all, so there may be something else going on here which I don't understand. Rich.
2016 Nov 04
10
[PATCH 0/5] Import directly from OVA tar archive if possible
This is still a draft, not ready for commit yet. But feedback is welcomed. This series is related to the problem of inefficient import of OVA files. The needed enhancements of QEMU was merged into the codebase and should be available in QEMU 2.8. From there we can use 'size' and 'offset' options in raw driver to tell QEMU to use only subset of a file as an image. The first three
2016 Nov 04
0
[PATCH 4/5] v2v: ova: don't extract files from OVA if it's not needed
...quot; ; file; "-C"; outdir ] in + if shell_command ((stringify_args cmd1) ^ " | " ^ (stringify_args cmd2) ^ " | " ^ (stringify_args cmd3)) <> 0 then + error (f_"error unpacking %s, see earlier error messages") ova in + match detect_file_type ova with | `Tar -> (* Normal ovas are tar file (not compressed). *) - untar ova tmpdir; - tmpdir + untar_partial ova tmpdir; + tmpdir, true | `Zip -> (* However, although not permitted by the spec, people ship...
2020 Apr 06
4
[v2v PATCH 1/2] v2v: nbdkit: change base dir for nbdkit sockets/pidfiles
Since this new temporary directory will contain UNIX sockets for communicating with nbdkit, then its path must not be too long. Use the existing directory that libguestfs exposes for this, i.e. sockdir. --- v2v/nbdkit.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/v2v/nbdkit.ml b/v2v/nbdkit.ml index 65317f9b..46b20c9d 100644 --- a/v2v/nbdkit.ml +++ b/v2v/nbdkit.ml
2016 Apr 21
2
[PATCH 1/2] sparsify: Refactor handling of checks of copying mode / --in-place.
Just refactoring, no change. --- sparsify/cmdline.ml | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/sparsify/cmdline.ml b/sparsify/cmdline.ml index ce2b913..bd49e71 100644 --- a/sparsify/cmdline.ml +++ b/sparsify/cmdline.ml @@ -98,6 +98,7 @@ read the man page virt-sparsify(1). let check_tmpdir = !check_tmpdir in let
2016 Dec 07
12
[PATCH v3 0/6] Import directly from OVA tar archive if possible
v3: Addressed Pino's comments, namely: - input_ova.ml - untar takes list of paths - renamed untar_partial to untar_metadata - replaced uggly regex with nsplit - tests - test changes are part of the main commit - renamed test-data/guestfs-hashsums.sh to test-data/test-utils.sh - renamed qemu_version to qemu_is_version and moved it to test-data/test-utils.sh - normalize paths