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

Add support for HVSOCK on hyperv #18167

Merged
merged 1 commit into from
Apr 17, 2023

Conversation

baude
Copy link
Member

@baude baude commented Apr 12, 2023

Windows HyperV uses HVSocks (Windows adaptation of vsock) for communicating between vms and the host. Podman machine in Qemu uses a virtual UDS to signal the host that the machine is booted. In HyperV, we can use a HVSOCK for the same purpose.

One of the big aspects of using HVSOCK on Windows is that the HVSOCK must be entered into the Windows registry. So now part of init and rm of a podman machine, entries must be added and removed respectively. Also duplicates are a no-no.

Does this PR introduce a user-facing change?

none

[NO NEW TESTS NEEDED]

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 12, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: baude

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

The pull request process is described 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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 12, 2023
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Needs another make vendor to pass CI.

I did not test the code, so it's only nits on the code.

pkg/machine/hyperv/machine.go Outdated Show resolved Hide resolved
pkg/machine/hyperv/vsock.go Show resolved Hide resolved
ready := `[Unit]
After=remove-moby.service sshd.socket sshd.service
OnFailure=emergency.target
OnFailureJobMode=isolate
Copy link
Member

Choose a reason for hiding this comment

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

Can you elaborate on the isolate choice? That means all/most other units are stopped. Is the idea to nuke everything if this unit fails?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is existing code that works like a charm today ... i didn't want to change anything ... plus it came from @dustymabe and he speaks fluent systemd ... i dont

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe a copy and paste from an existing service? I don't remember giving specific instruction to use that, but maybe I did.

The question is, what do you want to happen if this unit fails?

Copy link
Member Author

Choose a reason for hiding this comment

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

it cannot fail

Copy link
Contributor

Choose a reason for hiding this comment

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

then this should work like you want it to. basically the machine won't be up in a half state. it shuts everything down and drops you to a console.

Copy link
Member

Choose a reason for hiding this comment

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

Great! This is how I read the docs on isolate as well 👍 I haven't seen until reviewing the PR though.

pkg/machine/hyperv/vsock.go Outdated Show resolved Hide resolved
// ready is a unit file that sets up the virtual serial device
// where when the VM is done configuring, it will send an ack
// so a listening host knows it can being interacting with it
ready := `[Unit]
Copy link
Member

Choose a reason for hiding this comment

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

Consider moving the two units into a dedicated .go file as consts. Future changes/bug fixes may need to be applied to both units. If they're located in the same file, the risk of changing one but not the other is probably lower.

Copy link
Member Author

Choose a reason for hiding this comment

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

they are not the same though. thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I was more thinking about locality. Currently the units are hidden in the functions. Having them side-by-side may help future development/maintenance but that's more speculation.

@baude baude force-pushed the hypervvsock branch 2 times, most recently from 114a1a8 to d643737 Compare April 13, 2023 18:22
Windows HyperV uses HVSocks (Windows adaptation of vsock) for
communicating between vms and the host.  Podman machine in Qemu uses a
virtual UDS to signal the host that the machine is booted.  In HyperV,
we can use a HVSOCK for the same purpose.

One of the big aspects of using HVSOCK on Windows is that the HVSOCK
must be entered into the Windows registry.  So now part of init and rm
of a podman machine, entries must be added and removed respectively.
Also duplicates are a no-no.

Signed-off-by: Brent Baude <[email protected]>
Copy link
Member

@ashley-cui ashley-cui left a comment

Choose a reason for hiding this comment

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

Just one question and a tiny nit on a comment, probably not worth re-pushing for, if you're not fixing something else.

Other than this, LGTM

pkg/machine/hyperv/vsock.go Show resolved Hide resolved
return err
}
// Wait on notification from the guest
return m.ReadyHVSock.Listen()
Copy link
Member

Choose a reason for hiding this comment

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

Would there ever be an instance where Listen() hangs and doesn't return?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, but you can ctrl-c it. i believe qemu is doing this the same basic way.

pkg/machine/hyperv/vsock.go Show resolved Hide resolved
@ashley-cui
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 17, 2023
@openshift-merge-robot openshift-merge-robot merged commit ef4dbc2 into containers:main Apr 17, 2023
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 1, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants