Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IH-533: Remove usage of forkexecd daemon to execute processes #5581

Closed
wants to merge 4 commits into from

Commits on Apr 22, 2024

  1. IH-533: Remove usage of forkexecd daemon to execute processes

    Forkexecd was written to avoid some issues with Ocaml and
    multi-threading.
    Instead use C code to launch processes and avoid these issues.
    Interface remains unchanged from Ocaml side but implemntation rely
    entirely on C code.
    vfork() is used to avoid performance memory issue.
    Using fork() in XenPV guests is extremely expensive, currently forkexecd
    is calling 2 fork()s for each process launched.
    Reap of the processes are done directly.
    Code automatically reap child processes to avoid zombies.
    One small helper is used in case syslog redirection is used.
    This allows to restart the toolstack and keep launched programs running;
    note that even with forkexecd daemon one process was used for this
    purpose.
    Code tries to keep compability with forkexecd, in particular:
    - SIGPIPE disposition is set to ignore;
    - /dev/null is open with O_WRONLY even for stdin;
    - file descriptors are limited to 1024.
    We use close_range (if available) to reduce system calls to close
    file descriptors.
    Cgroup is set to avoid systemd closing processes on toolstack restart.
    There's a fuzzer program to check file remapping algorithm; for this
    reason the algorithm is in a separate file.
    
    To turn internal debug on you need to set FORKEXECD_DEBUG_LOGS C
    preprocessor macro to 1.
    
    Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
    freddy77 committed Apr 22, 2024
    Configuration menu
    Copy the full SHA
    7dd06b8 View commit details
    Browse the repository at this point in the history

Commits on Apr 26, 2024

  1. Address multiple review comments

    Add more comments to explain some implementations.
    Remove one optimization making code less readable.
    Do not use caml_stat_ calls for temporary C memory to potentially avoid
    Ocaml GC to trigger if runtime changes.
    Reduce log directory permissions, although disabled by default no
    reasons to beso wide.
    Make a macro more readable.
    
    Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
    freddy77 committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    820ce13 View commit details
    Browse the repository at this point in the history
  2. Report first error setting up file descriptors

    Although error code is never reset back better to stop and report
    as soon as possible, function could have been overridden.
    
    Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
    freddy77 committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    22e5f0b View commit details
    Browse the repository at this point in the history
  3. Close file before exiting forward_to_syslog

    Address a comment.
    
    Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
    freddy77 committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    7d3ecfa View commit details
    Browse the repository at this point in the history