-
Notifications
You must be signed in to change notification settings - Fork 378
krun: switch to passt-based networking #1913
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
Some handlers may need to preserve more fds than those related to stdio. Let's allow them to provide their own hook for doing that. Signed-off-by: Sergio Lopez <[email protected]>
Automatically start passt and use it for adding a virtio-net interface to the microVM. This allows us to have networking even when running generic kernels that doesn't support TSI. Signed-off-by: Sergio Lopez <[email protected]>
Reviewer's GuideThe PR integrates passt-based networking by launching a passt daemon with a UNIX socketpair, attaching a virtio-net interface to the microVM via krun_add_net_unixstream, and extending FD cleanup to preserve passt sockets. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
cc/ @sbrivio-rh for awareness |
|
Ephemeral COPR build failed. @containers/packit-build please check. |
| else | ||
| { | ||
| /* We need to make sure passt has already started before continuing. A | ||
| simple way to do it is with a blocking read on its stdout. */ |
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.
Actually, you can skip this whole dance by not passing -f: passt behaves like usual UNIX daemons and forks into background when it's ready, and if you give -1 / --one-off, it terminates by itself once the guest disconnects.
Conversely, getting something from its stdout doesn't guarantee that it's ready. Which is the only (minor) issue I spotted here, by the way, so if you need to stick to this approach for whatever reason it looks fine to me as well.
|
I think this would be amazing to have in crun! I did apply and run your patch and I can confirm that and I can't reach the network at all. I'm launching my container like this: Do I need some extra stuff? |
With Podman and pasta(1), you get networking automatically configured because Podman passes But there's no such thing in passt(1) as it can't magically enter your VM and do stuff there, so you need to use DHCP or SLAAC/NDP to configure the network in this case ( Maybe an approach similar to AsahiLinux/muvm#111 (tiny DHCP client embedded in muvm) would make sense here as well. |
|
Ah right, that makes a lot of sense. Sadly, it doesn't work: EDIT: |
It might be that you forgot to bring the interface up first? |
That's exactly what I was planning to do, basically by translating your Rust implementation into C for |
By the way, if you're looking for some quick-and-dirty netlink implementation, without using the full libnl, with pretty much just the parts you need to do that, you can probably draw some inspiration from https://passt.top/passt/tree/netlink.c or https://archives.passt.top/passt-dev/20231206160808.3d312733@elisabeth/. It's GPL code though, so you can't use it directly in libkrun's init (init/init.c is missing licensing information by the way). But I hope it helps anyway as documentation / how-to. Or maybe it's just more convenient to go with libnl, after all... |
Automatically start passt and use it for adding a virtio-net interface to the microVM. This allows us to have networking even when running generic kernels that doesn't support TSI.
Summary by Sourcery
Integrate passt-based networking into the krun handler by forking and exec’ing passt, wiring up a Unix stream socket for virtio-net via krun_add_net_unixstream, and updating file-descriptor management to support the new passt sockets.
New Features:
Enhancements: