Repository navigation
Conversation
c084670 to
d6607ac
Compare
d6607ac to
4b78c1d
Compare
I found when running locally that if `vde_switch` crashes, we just permanently end up in a state where its stdout appears readable, but we find no lines to read. I think this is a quirky interaction between nonblocking mode and the underlying implementation of `readline`. Whatever the root cause, I believe this is the correct fix: stdout is line buffered, so if it's readable, we should find a line. If we don't then the process must be dead. Also log the output at debug level while we're waiting for `vde_switch` to start. Previously we were blackholing it, which made debugging issues quite challenging.
This just moves the thing that should create the `ctl` folder (`vde_switch`) next to the assertion that it actually created it.
…er communication This is a POC: just looking for high level feedback right now. `vde_plug2tap` allows communication between our QEMU VMs (connected via `vde_switch`) and our systemd-nspawn containers (connected via Linux bridge interfaces). Unfortunately, it requires `/dev/net/tun` to create a TAP interface to hook into the bridge interfaces. `/dev/net/tun` is not normally present in the nix build sandbox, and folks have raised security concerns about making it available. TODO: citation needed, all I have right now is [this](NixOS/infra#987 (comment)). Here I've put together a proof of concept of an alternate implementation of `vde_plug2tap` that uses raw sockets instead of TAP interfaces. I haven't been able to find an existing project that does this, probably because it's unusual to be in a situation where you can create raw sockets (which requires root), but you cannot create TAP interfaces. From [Universal TUN/TAP device driver]: > There’s no harm in allowing the device [`/dev/net/tun`] to be > accessible by non-root users, since CAP_NET_ADMIN is required for > creating network devices or for connecting to network devices which > aren’t owned by the user in question. [Universal TUN/TAP device driver]: https://www.kernel.org/doc/html/latest/networking/tuntap.html
4b78c1d to
7e618a9
Compare
| # TODO: Only do this if necessary (it fails if we don't have pid 0 inside the sandbox). | ||
| # refs: <https://github.com/NixOS/nixpkgs/pull/511413#discussion_r3108252527> |
There was a problem hiding this comment.
This is why most tests are failing with these changes. I just wanted to put up a POC that shows that nix-build -A nixosTests.nixos-test-driver.containers does work without /dev/net/tun exposed in the build sandbox.
Ma27
left a comment
There was a problem hiding this comment.
I appreciate the dedication, but I'm really hesistant to having such a low-level tool that is essentially up to us, the people maintaining & developing the test-driver to maintain.
My worries are about maintainership itself, but also the chance of having to debug subtle bugs in our own code that make network debugging even harder inside VM tests. This is not to say that I don't trust this code in particular, but from experience, this feels pretty risky and I'd kinda like to avoid that.
That being said, as you indicated in your TODO-comment, have you reached out to the VDE project? Would be helpful to know what they think and if they'd be willing to take care of this.
/dev/net/tun is not normally present in the nix build sandbox, and folks have raised security concerns about making it available
Just to get this right, this isn't directly about purity concerns to not have it, but since that might be a vector to escape the sandbox in general (I wouldn't consider the Nix sandbox a security boundary, my point is rather about any sandbox solution passing through this device).
cc @RaitoBezarius who also seemed interested in having a non-sandbox-paths solution for this.
|
Everything you say totally makes sense, @Ma27. This was a "is it possible?" question I couldn't let go of.
I've been waiting to reach out to the vde folks until I can give them some sort of explanation about the risks associated with |
|
@jfly so, I've been chatting with @RaitoBezarius recently about the question whether/not this is a good idea and he signalled it's likely fine and the easiest solution for the time being, so I proposed https://gerrit.lix.systems/c/lix/+/5711 to the Lix project. Let's see how that goes. |
|
Hi @jfly , On Fulltime Nix Podcast, I listened to your explanations and problems of having an easier abstraction than Nspawn can provide especially around hardware like Storage, Networking, GPUs. I would like to see this effort pivot to use Incus (the community fork of LXD). Which can manage VMs and Containers and a much easier configuration management. Happy to work on this draft with you going forward to build a robust container/vm template system for building and testing NixOS and NixPkgs. |
|
Thanks, @thadguidry!
I'm not familiar with Incus. I think this question is better suited for the @NixOS/test-driver team. You may also want to take a look at #589203, which looks like it's adopting a different VM runner (test.thing). |
This is a POC: just looking for high level feedback right now.
With these changes, I am able to run
nix-build -A nixosTests.nixos-test-driver.containerswithout exposing/dev/net/tunin my nix sandbox.vde_plug2tapallows communication between our QEMU VMs (connected viavde_switch) and our systemd-nspawn containers (connected via Linux bridge interfaces). Unfortunately, it requires/dev/net/tunto create a TAP interface to hook into the bridge interfaces./dev/net/tunis not normally present in the nix build sandbox, and folks have raised security concerns about making it available. TODO: citation needed, all I have right now is this.Here I've put together a proof of concept of an alternate implementation of
vde_plug2tapthat uses raw sockets instead of TAP interfaces. I haven't been able to find an existing project that does this, probably because it's unusual to be in a situation where you can create raw sockets (which requires root), but you cannot create TAP interfaces. From Universal TUN/TAP device driver:Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.