search for: stdout_chan

Displaying 20 results from an estimated 31 matches for "stdout_chan".

2017 Jun 20
2
[PATCH v2 1/2] mllib: add new Common_utils.run_commands
...and ?(echo_cmd = true) cmd = ); lines -let run_command ?(echo_cmd = true) args = - if echo_cmd then - debug "%s" (stringify_args args); +let rec run_commands ?(echo_cmd = true) cmds = + let res = Array.make (List.length cmds) 0 in + let pids = + mapi ( + fun i (args, stdout_chan, stderr_chan) -> + let run_res = do_run args ?stdout_chan ?stderr_chan in + match run_res with + | Either (pid, app, outfd, errfd) -> + Some (i, pid, app, outfd, errfd) + | Or code -> + res.(i) <- code; + None + ) cmds in + let...
2018 Aug 17
8
[PATCH v3 4/4] v2v: Add --print-estimate option to print copy size
I rethought this again, as I think that it's a dangerous assumption to bake qemu-img measure output into our API. This patch series runs qemu-img measure behind the scenes, but then parses the output and sums it to a single number which we print. Doing that required a bit of reworking, moving the Jansson [JSON parser] bindings from virt-builder into the common directory and a couple of other
2017 Jul 19
2
Re: [PATCH 02/27] daemon: Allow parts of the daemon and APIs to be written in OCaml.
...ed to do fixes & additions in both places. > + if verbose () then > + eprintf "command: %s %s\n%!" > + prog (String.concat " " args); stringify_args could help here. > + let argv = Array.of_list (prog :: args) in > + > + let stdout_file, stdout_chan = Filename.open_temp_file "cmd" ".out" in > + let stderr_file, stderr_chan = Filename.open_temp_file "cmd" ".err" in > + let stdout_fd = descr_of_out_channel stdout_chan in > + let stderr_fd = descr_of_out_channel stderr_chan in > + let stdin_...
2017 Nov 14
1
Re: [PATCH v12 3/3] New tool: virt-builder-repository
...+ let cmd = [ "xz"; "-f"; "--best"; "--block-size=16777216"; "-c"; file ] in > + let file_flags = [ Unix.O_WRONLY; Unix.O_CREAT; Unix.O_TRUNC; ] in > + let outfd = Unix.openfile outimg file_flags 0o666 in > + let res = run_command cmd ~stdout_chan:outfd in I read the code of run_command but I don't think it closes outfd, and so outfd would be leaked here. Also it'd be nice to use with_openfile, if it was upstream. https://www.redhat.com/archives/libguestfs/2017-November/msg00028.html Pino ^ x 2 ? > + if res <> 0 then...
2017 Jul 14
0
[PATCH 02/27] daemon: Allow parts of the daemon and APIs to be written in OCaml.
...rog = + try ignore (which prog); true + with Executable_not_found _ -> false + +let commandr prog args = + if verbose () then + eprintf "command: %s %s\n%!" + prog (String.concat " " args); + + let argv = Array.of_list (prog :: args) in + + let stdout_file, stdout_chan = Filename.open_temp_file "cmd" ".out" in + let stderr_file, stderr_chan = Filename.open_temp_file "cmd" ".err" in + let stdout_fd = descr_of_out_channel stdout_chan in + let stderr_fd = descr_of_out_channel stderr_chan in + let stdin_fd = openfile "...
2017 Jun 03
3
[PATCH 0/3]: daemon: Reimplement ‘file’ API in OCaml.
This patch series is just FYI at the moment. However it does pass the tests. The daemon is a self-contained program. We don't need to write it all in C. Writing parts of it in OCaml would make it simpler and less error-prone. In particular if the daemon was written in a more sane programming language then we could move the inspection code to run entirely inside the appliance, which would
2017 Oct 08
0
[PATCH v2 3/4] common/mlstdutils: Introduce Option submodule.
...estfs () in if trace () then g#set_trace true; if verbose () then g#set_verbose true; - may g#set_identifier identifier; + Option.may g#set_identifier identifier; g (* All the OCaml virt-* programs use this wrapper to catch exceptions @@ -340,8 +340,8 @@ and do_run ?(echo_cmd = true) ?stdout_chan ?stderr_chan args = Or 127 and do_teardown app outfd errfd exitstat = - may Unix.close outfd; - may Unix.close errfd; + Option.may Unix.close outfd; + Option.may Unix.close errfd; match exitstat with | Unix.WEXITED i -> i diff --git a/customize/customize_main.ml b/customiz...
2017 Jul 21
0
[PATCH v2 01/23] daemon: Allow parts of the daemon and APIs to be written in OCaml.
...OnStderr flags in + + if verbose () then + eprintf "command: %s %s\n%!" + (if fold_stdout_on_stderr then " fold-stdout-on-stderr" else "") + (stringify_args (prog :: args)); + + let argv = Array.of_list (prog :: args) in + + let stdout_file, stdout_chan = Filename.open_temp_file "cmd" ".out" in + let stderr_file, stderr_chan = Filename.open_temp_file "cmd" ".err" in + let stdout_fd = descr_of_out_channel stdout_chan in + let stderr_fd = descr_of_out_channel stderr_chan in + let stdin_fd = openfile "...
2017 Sep 18
0
[PATCH v9 7/7] New tool: virt-builder-repository
...ng ...%!"; + let cmd = [ "xz"; "-f"; "--best"; "--block-size=16777216"; "-c"; file ] in + let file_flags = [ Unix.O_WRONLY; Unix.O_CREAT; Unix.O_TRUNC; ] in + let outfd = Unix.openfile outimg file_flags 0o666 in + let res = run_command cmd ~stdout_chan:outfd in + if res <> 0 then + error (f_"i‘xz’ command failed"); + outimg + +let get_mime_type filepath = + let file_cmd = "file --mime-type --brief " ^ (quote filepath) in + match external_command file_cmd with + | [] -> "" + | lines -> List.hd lin...
2017 Oct 05
0
[PATCH v11 6/6] New tool: virt-builder-repository
...ng ...%!"; + let cmd = [ "xz"; "-f"; "--best"; "--block-size=16777216"; "-c"; file ] in + let file_flags = [ Unix.O_WRONLY; Unix.O_CREAT; Unix.O_TRUNC; ] in + let outfd = Unix.openfile outimg file_flags 0o666 in + let res = run_command cmd ~stdout_chan:outfd in + if res <> 0 then + error (f_"‘xz’ command failed"); + outimg + +let get_mime_type filepath = + let file_cmd = "file --mime-type --brief " ^ (quote filepath) in + match external_command file_cmd with + | [] -> None + | line :: _ -> Some line + +let...
2017 Sep 12
0
[PATCH v8 7/7] Add a virt-builder-repository tool
...ng ...%!"; + let cmd = [ "xz"; "-f"; "--best"; "--block-size=16777216"; "-c"; file ] in + let file_flags = [ Unix.O_WRONLY; Unix.O_CREAT; Unix.O_TRUNC; ] in + let outfd = Unix.openfile outimg file_flags 0o666 in + let res = run_command cmd ~stdout_chan:outfd in + if res <> 0 then + error (f_"'xz' command failed"); + outimg + +let get_mime_type filepath = + let file_cmd = "file --mime-type " ^ (quote filepath) in + let output = List.hd (external_command file_cmd) in + let _, mime = String.split ":&quo...
2017 Nov 13
6
[PATCH v12 0/3] virt-builder-repository tool
Hi there! Here is the latest version of the series including Richard's comments. I also reworked the repository_main.ml code to avoid setting an empty entry if not found. Cédric Bosdonnat (3): builder: change arch type to distinguish guesses builder: add a template parameter to get_index New tool: virt-builder-repository .gitignore | 4 +
2017 Nov 13
0
[PATCH v12 3/3] New tool: virt-builder-repository
...ng ...%!"; + let cmd = [ "xz"; "-f"; "--best"; "--block-size=16777216"; "-c"; file ] in + let file_flags = [ Unix.O_WRONLY; Unix.O_CREAT; Unix.O_TRUNC; ] in + let outfd = Unix.openfile outimg file_flags 0o666 in + let res = run_command cmd ~stdout_chan:outfd in + if res <> 0 then + error (f_"‘xz’ command failed"); + outimg + +let get_mime_type filepath = + let file_cmd = "file --mime-type --brief " ^ (quote filepath) in + match external_command file_cmd with + | [] -> None + | line :: _ -> Some line + +let...
2017 Sep 20
6
[PATCH v10 0/6] virt-builder-repository
Hi all, Diff to v9 includes the changes requested by Pino. Cédric Bosdonnat (5): builder: rename docs test script builder: add a template parameter to get_index builder: add Index.write_entry function mllib: add XPath helper xpath_get_nodes() New tool: virt-builder-repository Pino Toscano (1): builder: add simple OCaml osinfo-db reader .gitignore
2017 Nov 21
5
[PATCH v13 0/3] virt-builder-repository
Hey there, Here is an update of the series. The changes: * Incorporate Richard's comments. Left out the with_openfile one since that leads to a double close. * Change the ask option return type to string (removing the option) since if the use doesn't input anything we're using the default, and the default is now a mandatory parameter. * Make sure there are items in the
2017 Sep 18
11
[PATCH v9 0/7] virt-builder-repository
Hi there, Diffs to v8: * Remove the regex to increment the revision: Index_parser.get_entry() only handles integers * Fix Pino's comments Cédric Bosdonnat (6): builder: rename docs test script builder: add a template parameter to get_index builder: add Index.write_entry function mllib: add XPath helper xpath_get_nodes() builder: remove useless fish dependency New tool:
2017 Sep 12
10
[PATCH v8 0/7] virt-builder-repository tool
Hi all, Here is the latest iteration on the virt-builder-repository series. Diffs to previous version are: fixing things mentioned by Pino, integrate Pino's osinfo ocaml iterator and adding a check of the mime type to filter potential image files. Cédric Bosdonnat (6): builder: rename docs test script builder: add a template parameter to get_index builder: add Index.write_entry
2017 Jul 14
45
[PATCH 00/27] Reimplement many daemon APIs in OCaml.
Previously posted as part of the mega utilities/inspection series here: https://www.redhat.com/archives/libguestfs/2017-June/msg00232.html What I've done is to extract just the parts related to rewriting daemon APIs in OCaml, rebase them on top of the current master, fix a few things, and recompile and test everything. Rich.
2017 Jun 03
12
[PATCH v2 00/12] Allow APIs to be implemented in OCaml.
Version 1 was here: https://www.redhat.com/archives/libguestfs/2017-June/msg00003.html This patch series reimplements a few more APIs in OCaml, including some very important core APIs like ?list_filesystems? and ?mount?. All the tests pass after this. The selection of APIs that I have moved may look a little random, but in fact they are all APIs consumed by the inspection code (and some more
2017 Oct 05
14
[PATCH v11 0/6] virt-builder-repository
Hi there, This is an update of the series. Just to rebase it on top of Rich's latest changes. Cédric Bosdonnat (5): builder: rename docs test script builder: add a template parameter to get_index builder: add Index.write_entry function mllib: add XPath helper xpath_get_nodes() New tool: virt-builder-repository Pino Toscano (1): builder: add simple OCaml osinfo-db reader