-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support for binfmt_misc in build sandboxes #2561
Comments
cc @cleverca22, since you have the following snippet in your repo: https://github.com/cleverca22/nixos-configs/blob/18baf13c0fd1eac3516cd0a39481108077ac7654/qemu.nix |
I think this can only work if its reflected in the derivation that it's running under a particular binfmt_misc interpreter. In @cleverca22 's patch, the derivations pretend to be native versions of the target, which is definitely not a reasonable assumption. |
If that's covered and it doesn't break the sandbox, sounds like a great addition IMO. |
Yes could be some extension of |
|
The problem with binfmt_misc is that it requires Linux kernel configuration for it to work. There's no real way to force everyone to have it configured properly. I don't think there is anything similar in other kernels either. It also comes with a little too much "magic" in my opinion. A builder should only be able to execute from one architecture, adding more could lead to bad behavior (for instance using the cross compiler when the native compiler should be used). I recently merged something that I think avoids the magic part of binfmt_misc. It is just a generic "emulator" that you can use to get a qemu-user for any platform. It can be used like this:
This makes the "magic" a little more explicit. It can use either qemu-user or wine depending on what stdenv.hostPlatform is. |
Does the emulator also work if a process forks and execute a different non-native binary? Regarding the kernel configuration we still have to wait if that is become the default, which is what I expect. All current implemented namespaces are enabled by default. We also will not be able to use it for some time in nixpkgs, but that does not mean it is not usable for anybody. |
How does this interact with NixOS/nixops#574 ? |
Not at all. |
I marked this as stale due to inactivity. → More info |
We still don't have binfmt_misc namespaces unfortunately. |
I marked this as stale due to inactivity. → More info |
Those patches never made into the kernel. |
Since we now get more and more software cross-compiled it will be useful
to also emulate non-native architectures to work-around unwilling buildsystems
and for testing. The kernel supports user-defined binfmt_misc magics, but
this can be only done as root and globally at the moment.
However there are promising patches for the linux kernel proposed that could solve this in future: https://patchwork.kernel.org/cover/10634807/
In short this would allow to register per build sandbox custom binary formats
to start qemu/wine emulators as needed. This feature will not require root privileges.
The text was updated successfully, but these errors were encountered: