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

connect over stdio #177

Merged
merged 1 commit into from
Feb 14, 2023
Merged

connect over stdio #177

merged 1 commit into from
Feb 14, 2023

Conversation

sakai135
Copy link
Contributor

@sakai135 sakai135 commented Jan 31, 2023

This adds stdio as a way to communicate between gvproxy and vm mainly for use with WSL2, although it should work for other cases as well.

When network connections between WSL2 and the Windows host are blocked, stdio is the only reliable way to establish a channel between WSL2 and the Windows host. Hyper-V socket for WSL2 is a possibility, but it requires undocumented APIs and admin privileges.

Related to #139. Related: microsoft/WSL#4131

@gbraad
Copy link
Member

gbraad commented Feb 8, 2023

@sakai135 I understood from others on this repo that they lack context why this is proposed. Perhaps you can add this a little on the technical side?

This is a possible change to allow an easier integration of the needed parts to make the usermode networkstack work for WSL2. Originally an alternative client for wsl+vm was necessary. The only concerns is that performance might be a problem. WDYT?

@cfergeau
Copy link
Collaborator

cfergeau commented Feb 8, 2023

What is not clear to me is why this has to go over stdio instead of other channels (some kind of pipe/socket/file descriptor/...). I'm sure there are very good reasons for that, but it would help to state these :)

@sakai135
Copy link
Contributor Author

sakai135 commented Feb 8, 2023

@cfergeau updated the PR description with the reasons for using stdio

cmd/gvproxy/main.go Outdated Show resolved Hide resolved
@@ -275,7 +283,7 @@ func run(ctx context.Context, g *errgroup.Group, configuration *types.Configurat
for {
select {
case <-time.After(5 * time.Second):
fmt.Printf("%v sent to the VM, %v received from the VM\n", humanize.Bytes(vn.BytesSent()), humanize.Bytes(vn.BytesReceived()))
log.Debugf("%v sent to the VM, %v received from the VM\n", humanize.Bytes(vn.BytesSent()), humanize.Bytes(vn.BytesReceived()))
Copy link
Member

Choose a reason for hiding this comment

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

:+1

test/wsl.sh Outdated
set -x

./bin/vm \
-url="stdio:/home/ubuntu/gvisor-tap-vsock/bin/gvproxy-windows.exe?listen-stdio=accept&debug=true" \
Copy link
Member

Choose a reason for hiding this comment

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

can this work with $HOME ? There is no ubuntu user on Fedora ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used pwd to make it a bit more flexible.

@sakai135 sakai135 requested review from gbraad and removed request for n1hility and cfergeau February 10, 2023 00:42
@n1hility
Copy link
Member

LGTM thanks for the PR

btw I assume the usage of PID is for local and remote addressing is debugging?

@n1hility
Copy link
Member

Regarding usage of stdio, another longer term option that could be explored in the future would be a reverse ssh forwarded connection to a unix socket (sort of like what we do for API forwarding but flipped)

@sakai135
Copy link
Contributor Author

@n1hility Yes, the local/remote address is just for debugging.

"strconv"
)

var execCommand = exec.Command
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason for this indirection?

Apart from this, looks good to me, could you squash all the commits together, and add the PR description as the commit log?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This adds stdio as a way to communicate between gvproxy and vm mainly for use
with WSL2, although it should work for other cases as well.

When network connections between WSL2 and the Windows host are blocked, stdio
is the only reliable way to establish a channel between WSL2 and the Windows
host. Hyper-V socket for WSL2 is a possibility, but it requires undocumented
APIs and admin privileges.

Signed-off-by: Keiichi Shimamura <[email protected]>
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 14, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: cfergeau, sakai135

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cfergeau cfergeau merged commit 17048f5 into containers:main Feb 14, 2023
@gbraad
Copy link
Member

gbraad commented Feb 14, 2023

👍

@gbraad
Copy link
Member

gbraad commented Feb 14, 2023

@sakai135 @cfergeau time to cut a new release?

@cfergeau
Copy link
Collaborator

There's another pending PR #175

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

Successfully merging this pull request may close these issues.

4 participants