Add dynamic UNIX socket forwarding#47
Conversation
Unconditionally forward a range of ports to sockets named `$XDG_RUNTIME_DIR/krun/socket/port-$PORT`. This allows applications to dynamically bind to sockets at those paths and have them forwarded to the guest as vsock ports, after the krun VM is already running. The port range is currently hardcoded as 50000..50200. Signed-off-by: Asahi Lina <lina@asahilina.net>
|
Would it make more sense for the port range to be configurable? The app will have to do directory traversal to figure out which ports are forwarded anyway, right? Otherwise what should happen when a port is already in use? |
|
I think we need some way to tell apps what port range is available, I was thinking maybe a flag file in the directory? Apps would have to then pick the first nonexistent socket/port to bind to. |
|
Looks good. We should probably make the port range configurable via args with good defaults. As for how to coordinate port numbers across guest and host, giving that we expect most application launches to be initiated from the host, a reasonable approach could be delegating this responsibility to the application itself, like this:
If this approach works for us, the only change in this PR would be making the port range configuration (and even than isn't a strong requirement from me). |
Unconditionally forward a range of ports to sockets named
$XDG_RUNTIME_DIR/krun/socket/port-$PORT. This allows applications to dynamically bind to sockets at those paths and have them forwarded to the guest as vsock ports, after the krun VM is already running.The port range is currently hardcoded as 50000..50200.