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 TLS and SSH Dialers, and support libvirt URI parsing #209

Merged
merged 7 commits into from
Feb 20, 2024

Conversation

zaneb
Copy link
Contributor

@zaneb zaneb commented Feb 19, 2024

Add a Dialer for TLS connections. This removes the need for consumers of the library to write a lot of TLS setup code, and abstracts the weird part of the connection protocol discussed in #89.

Add a Dialer for SSH connections, using the golang stdlib ssh library.

Introduce a function to connect to an arbitrary libvirt connection URI. This removes the need for every consumer to reimplement this functionality if they want user-configurable connection parameters, and greatly simplifies the process of opening a connection. The transports that are implemented are unix, tcp, tls, libssh2, libssh, and ssh.

Note that for now all 3 of the ssh transports are implemented using the same golang ssh library for connection, so the behaviour may not always be identical to the libvirt client (in particular the ssh transport would normally be expected to pick up settings from the user's .ssh/config file by virtue of it shelling out to the ssh client).

Fixes #139
Fixes #143
Fixes #189

@zaneb zaneb requested a review from a team as a code owner February 19, 2024 03:25
zaneb added a commit to zaneb/openshift-installer that referenced this pull request Feb 20, 2024
This is a static (pure golang) library that is used by the libvirt
terraform module. Import it in the top-level go module.

For now we use a replace directive while we wait for connection URI
support (including TLS and SSH dialers) to land upstream in
digitalocean/go-libvirt#209.
Copy link
Member

@trapgate trapgate left a comment

Choose a reason for hiding this comment

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

Thanks for this submission! go-libvirt has needed better TLS support for a long time.

@trapgate
Copy link
Member

Hang in there. The CI setup for go-libvirt has gotten a little long-in-the-tooth and needed updating. I've got a separate PR open to fix that; once it has merged you can update this PR and the tests should succeed.

@trapgate
Copy link
Member

The CI updates are merged; if you pull the latest changes into your fork the tests should pass.

When opening a connection with the libvirt client, the provided URI is
first used to set up the socket used to communicate with libvirtd. The
actual URI passed to libvirtd (i.e. when calling the ConnectToURI()
method) contains only a subset of the original, since relative to
libvirtd the underlying virt provider is always local.

Create a new ConnectToURI() function that returns a connected Libvirt
using the appropriate dialer and remote URI.
This is a simpler way to initiate a connection.
All of the hard parts are now implemented by the dialer, so the example
can be much more straightforward.
This is needed for ssh support.
Resolve qemu+ssh:// URIs using the internal (golang ssh library--based)
ssh dialer. Note that this cannot respect the system ssh configuration,
as users of the libvirt client library would (since it shells out to the
ssh binary for these URIs, unlike for qemu+libssh:// or qemu+libssh2://
URIs).
@zaneb
Copy link
Contributor Author

zaneb commented Feb 20, 2024

Thanks! Rebased the branch on that CI change.

@trapgate trapgate merged commit fcabe97 into digitalocean:master Feb 20, 2024
3 checks passed
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.

Connecting to Libvirt Tunnel via SSH? Support for connection URIs
2 participants