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

Support for lima usernet network #1383

Merged
merged 1 commit into from
May 4, 2023

Conversation

balajiv113
Copy link
Member

@balajiv113 balajiv113 commented Feb 24, 2023

fixes #1222

This PR adds support for the following,

  • Lima Usernet (Provides host -> vm, vm <-> vm communication)
  • Usernet as daemon and support for reconciler similar to socket_vmnet
  • New property added in yaml usernet.enabled, defaults to false. If its set to true, lima usernet will replace the slirp network

Todo items

  • Handle timeout in usernet client
  • Example template
  • Test for Performance issues
  • Writing integration test (Atleast for QEMU)
  • Documentation

@balajiv113 balajiv113 force-pushed the full-network branch 6 times, most recently from 156fcce to 46ac22d Compare February 24, 2023 14:36
@@ -31,6 +31,7 @@ type LimaYAML struct {
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
DNS []net.IP `yaml:"dns,omitempty" json:"dns,omitempty"`
HostResolver HostResolver `yaml:"hostResolver,omitempty" json:"hostResolver,omitempty"`
UserNet UserNet `yaml:"userNet,omitempty" json:"userNet,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems confusing to have two network options both called "user"...

https://wiki.qemu.org/Documentation/Networking#User_Networking_(SLIRP)

Originally posted by @afbjorklund in #1222 (comment)

Copy link
Member

@AkihiroSuda AkihiroSuda Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bikeshedding:

  • gvisor (confusing because it does not use gvisor's process sandbox)
  • gvisor-tap-vsock (confusing because it is not gvisor, nor tap, nor vsock)
  • netstack (confusing because any networking can be called "net(work) stack"
  • user-v2 (confusing because there was no user-v1)
  • modern (confusing because it can be eventually legacy)

Edit

  • builtin
  • multivm
  • multi-vm
  • vm-to-vm
  • vm2vm
  • v2v

Copy link
Member

@afbjorklund afbjorklund Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it would be OK to name both of them "user", and then toggle the slirp vs gvisor later ?

Just was afraid that we would have one called "user" and a different one called "usernet"...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am bit confused on this "two network options both called user"

As of now we don't have any configuration for slirp right?
And the one we provide now will be more a toggle, if enabled will use the latest or revert to the old modal ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is called user in qemu, is what I meant. If there is an option called usernet in lima too, it is confusing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or "multivm", "multi-vm", "vm-to-vm", "vm2vm", "v2v"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me the following suggestions looks good,

  • user-v2 as this give support for giving further versions as well like user-v3 etc.
  • builtin since usernet command is within limactl it kind of makes sense as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what happened with "user-v1", is that the normal one ? But "user-v2" seems complicated to me, as a yaml default. But maybe it needs versioning (as per above, "user-v3", "user-v4") otherwise "builtin" is simpler.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about calling it "builtin"

My vote is for builtin

@balajiv113
Copy link
Member Author

Marking PR as ready for review as the code looks lot better compared to the initial version.

There are some todo items but i think it can be done incrementally as well. Should not affect the current code much.
Will start with documentation as a last item once naming are finalised

@balajiv113 balajiv113 marked this pull request as ready for review February 28, 2023 18:34
@balajiv113
Copy link
Member Author

Testing for performance are done as well.

I tested in M1 with some long running instance (for more than a day with sleep). Haven't faced any issues (There was slight degrade when did iperf3, but on restarting iperf3 -s on host the performance was back to more meaningful value)

Also performance of QEMU is improved with this PR containers/gvisor-tap-vsock#188

Performance report
VZ <-> Host

$ iperf3 -c host.lima.internal
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  2.64 GBytes  2.27 Gbits/sec    0             sender
[  5]   0.00-10.02  sec  2.64 GBytes  2.26 Gbits/sec                  receiver

iperf Done.
$ iperf3 -c host.lima.internal -R
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  2.02 GBytes  1.73 Gbits/sec    0             sender
[  5]   0.00-10.00  sec  2.02 GBytes  1.73 Gbits/sec                  receiver

QEMU <-> Host

$ iperf3 -c host.lima.internal
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  1.84 GBytes  1.58 Gbits/sec    0             sender
[  5]   0.00-10.00  sec  1.84 GBytes  1.58 Gbits/sec                  receiver

iperf Done.
$ iperf3 -c host.lima.internal -R
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  1.21 GBytes  1.04 Gbits/sec    0             sender
[  5]   0.00-10.00  sec  1.21 GBytes  1.04 Gbits/sec                  receiver

iperf Done.

VZ <-> QEMU

$ iperf3 -c 192.168.5.1
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  1.44 GBytes  1.24 Gbits/sec    0             sender
[  5]   0.00-10.07  sec  1.44 GBytes  1.23 Gbits/sec                  receiver

iperf Done.
$ iperf3 -c 192.168.5.1 -R
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.04  sec  1.83 GBytes  1.57 Gbits/sec    0             sender
[  5]   0.00-10.00  sec  1.83 GBytes  1.57 Gbits/sec                  receiver

iperf Done.

@AkihiroSuda
Copy link
Member

Support video display for vz

Seems mixed up with a different PR

@@ -0,0 +1,15 @@
# Example to run vz instance with lima usernet enabled
Copy link
Member

@AkihiroSuda AkihiroSuda Mar 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usernet.yaml

usernet-v2.yaml, or maybe net-user-v2.yaml
(If we are going to call the new network as user-v2)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will rename this once the name is decided in above comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@afbjorklund
Copy link
Member

afbjorklund commented Mar 7, 2023

Here is what I got:

? Creating an instance "usernet" Proceed with the current configuration
FATA[0001] the YAML is invalid, saved the buffer as "lima.REJECTED.yaml": field `networks[0].lima` is only supported on macOS right now 
FATA[0000] vm driver 'vz' needs macOS 13 or later (Hint: try recompiling Lima if you are seeing this error on macOS 13) 
FATA[0000] field `mountType` must be "reverse-sshfs" or "9p" for QEMU driver , got "virtiofs" 

And eventually:

"level":"fatal","msg":"template: :1:21: executing \"\" at \u003cfd_connect \"/home/anders/.lima/_networks/usernet_default_qemu.sock\"\u003e: error calling fd_connect: fd_connect: dial unix /home/anders/.lima/_networks/usernet_default_qemu.sock: connect: no such file or directory"

@balajiv113
Copy link
Member Author

Missed support for linux with networks.lima property.
Will fix it. Thanks 👍

@balajiv113
Copy link
Member Author

@afbjorklund
Done changes to support linux, can you check if it works now :)

@jandubois
Copy link
Member

@afbjorklund @jandubois
WDYT?

To be honest, I kind of like the name "usernet". I'm also not confusing it with QEMU networking, as I always think of that one as SLIRP. "User mode networking" is just the general category, and SLIRP is a specific instance of it.

Now, you could argue that we should not use the category name ("user mode networking") and usurp it for the specific Lima implementation, but again personally I'm not bothered by it because it is disambiguated by context (it is the Lima usernet). I think descriptive names are good.

And if we ever need another name, and still can't come up with anything better, then we can still use usernet-v2. But maybe (hopefully) we will just have some different configuration parameter to tweak the implementation instead of having to replace it wholesale again.

@AkihiroSuda
Copy link
Member

AkihiroSuda commented Mar 14, 2023

To be honest, I kind of like the name "usernet". I'm also not confusing it with QEMU networking, as I always think of that one as SLIRP. "User mode networking" is just the general category, and SLIRP is a specific instance of it.

"slirp" has become a general category too.
Docker calls VPNKit as "slirp", although its implementation is different from the original slirp.
(Not an important topic here though)

@jandubois
Copy link
Member

I have no strong feelings about the name. I prefer usernet, but I can also live with user-v2 if that is what everyone else prefers.

Just to throw something else out: How about tunnel, because that's what it does, or at least what we use it for.

Not even sure if I like it myself though; might delete later. 🤣

@balajiv113 balajiv113 force-pushed the full-network branch 2 times, most recently from 48c408d to 00a3f9d Compare April 7, 2023 07:34
for ipAddr, leaseAddr := range leases {
if vmMacAddr == leaseAddr {
err = c.delegate.Expose(&types.ExposeRequest{
Local: fmt.Sprintf(":%d", sshPort),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Local: fmt.Sprintf(":%d", sshPort),
Local: fmt.Sprintf("127.0.0.1:%d", sshPort),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/-/_/ in the filename

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@balajiv113 balajiv113 force-pushed the full-network branch 2 times, most recently from 9a5535a to 0a7451f Compare April 7, 2023 11:20
- location: "~"
- location: "/tmp/lima"
writable: true
mountType: "virtiofs"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,15 @@
# Example to run vz instance with experimental user-v2 network enabled
vmType: "vz"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@balajiv113 balajiv113 force-pushed the full-network branch 2 times, most recently from 15953b8 to 20b34b5 Compare April 8, 2023 07:01
@AkihiroSuda
Copy link
Member

Sorry needs another rebase

Signed-off-by: Balaji Vijayakumar <[email protected]>
@balajiv113
Copy link
Member Author

@AkihiroSuda - Done :)

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda
Copy link
Member

@jandubois @afbjorklund May I merge this, or do you want to take the final look before merging?

@jandubois
Copy link
Member

May I merge this, or do you want to take the final look before merging?

I did want to review it, but I continue to be out of time. Feel free to merge if you are ok with it. At least it gets it into more people's hands for testing.

@alejandroiglesias
Copy link

Any chance of releasing this? It seems it would fix some issues I'm having.

@AkihiroSuda
Copy link
Member

Any chance of releasing this? It seems it would fix some issues I'm having.

Yes, probably next week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable guest-to-guest networking by default, with (gvisor-based) usermode networking
6 participants