-
Notifications
You must be signed in to change notification settings - Fork 90
Implement the ability to record the exit code from the entrypoint in userspace #312
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
base: main
Are you sure you want to change the base?
Conversation
slp
commented
Apr 9, 2025
Fixes #306, containers/crun#1694 and containers/crun#1688 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, but please add some documentation to krun_start_enter
about the special exit codes. I would say they are now part of our public API - podman relies on them to fix the mentioned issues.
For the container use case, we need to relay the exit code from userspace in the microVM all the way to the process using libkrun to launch the VMM. Since ioctls are passed mostly unmodified from userspace in the guest to the virtio-fs device, we can use them as a mechanism for transporting this information without requiring any specific support in the guest's kernel. Here we create an AtomicI32 and wire it up between virtio-fs and Vmm, using it as exit code if userspace has set it to some value other than i32::MAX. Otherwise, we keep using the vCPU exit code, as we did before. Signed-off-by: Sergio Lopez <[email protected]>
We already fixed this for Linux a while ago, do the same for the macOS implementation. Signed-off-by: Sergio Lopez <[email protected]>
Use the newly added exit code recording feature in virtio-fs to record the exit code from workload's entrypoint. We need to stop ignoring SIGCHLD, as otherwise waitpid doesn't record the exit code of our child, which also means we need to do a waitpid on every children to ensure we aren't leaving zombie processes. Signed-off-by: Sergio Lopez <[email protected]>
I think I've addressed all the feedback. |
For consistency for the container isolation use case, let's use in init the same exit codes as chroot and podman do: 125: "init" cannot set up the environment inside the microVM. 126: "init" can find the executable to be run inside the microVM but cannot not execute it. 127: "init" cannot find the executable to be run inside the microVM. Co-authored-by: Matej Hrica <[email protected]> Signed-off-by: Sergio Lopez <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now!