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 native driver specific guest agent connection #1998

Merged
merged 1 commit into from
Nov 17, 2023

Conversation

balajiv113
Copy link
Member

@balajiv113 balajiv113 commented Nov 14, 2023

Implementation for #1925

Advantages

  • Relies on native driver way of host <-> guest communication
  • Works even without network
  • No extra round trip like in ssh forwarding
  • Less load on network

Tasks

  • Vz support
  • qemu support
  • windows vsock support
  • Testing and clean-up

@balajiv113 balajiv113 force-pushed the guestconn branch 4 times, most recently from 49d6db2 to 85be61b Compare November 14, 2023 10:28
@balajiv113 balajiv113 marked this pull request as ready for review November 14, 2023 10:28
@balajiv113 balajiv113 force-pushed the guestconn branch 2 times, most recently from a6dca6a to 853e43b Compare November 14, 2023 11:37
var (
vSockPort = 0

qemuFile = "/dev/virtio-ports/lima.guest_agent.0"
Copy link
Member

Choose a reason for hiding this comment

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

Could you document these virtio ports in https://lima-vm.io/docs/dev/internals/ ?

Copy link
Member

Choose a reason for hiding this comment

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

Also, "qemuFile" sounds confusing.
Maybe this should be called virtioPort ?

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
qemuFile = "/dev/virtio-ports/lima.guest_agent.0"
virtioPort = "/dev/virtio-ports/io.lima-vm.guest_agent.0"

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

else
sudo "${LIMA_CIDATA_GUEST_INSTALL_PREFIX}"/bin/lima-guestagent install-systemd
fi
sudo "${LIMA_CIDATA_GUEST_INSTALL_PREFIX}"/bin/lima-guestagent install-systemd --vsock-port "${LIMA_CIDATA_VSOCK_PORT}"
Copy link
Member

@AkihiroSuda AkihiroSuda Nov 14, 2023

Choose a reason for hiding this comment

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

--vsock-port shouldn't be specified for qemu mode?

Copy link
Member Author

Choose a reason for hiding this comment

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

True but by default the port will be 0 for qemu so either way it will be ignored

pkg/qemu/qemu.go Outdated
const MinimumQemuVersion = "4.0.0"
const (
MinimumQemuVersion = "4.0.0"
LimaGuestSock = "lima-guest.sock"
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 be called ga.sock to match ha.sock ?

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 was un-used, removed it

Signed-off-by: Balaji Vijayakumar <kuttibalaji.v6@gmail.com>
@@ -49,6 +49,7 @@ func installSystemdAction(cmd *cobra.Command, _ []string) error {
args := [][]string{
{"daemon-reload"},
{"enable", "--now", "lima-guestagent.service"},
{"try-restart", "lima-guestagent.service"},
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 was needed to properly upgrade on first start.

Without this, the below case was failing
lima 0.15 create and start -> stop -> lima 1 start -> guest is updated but not restarted to pick up latest one -> This will be taken only after second restart

Each drivers use their own mode of communication
- `qemu`: uses virtio-port `io.lima-vm.guest_agent.0`
- `vz`: uses vsock port 2222
- `wsl2`: uses free random vsock port
Copy link
Member

Choose a reason for hiding this comment

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

Can't we use a random port for vz too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Vz create port on per vm basis so there is no way to get it ahead of time.

Since we are bootstrapping the vm i think we can be sure that it will be free

@AkihiroSuda AkihiroSuda added this to the v0.18.1 milestone Nov 17, 2023
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 AkihiroSuda merged commit f9ea34c into lima-vm:master Nov 17, 2023
24 checks passed
@balajiv113 balajiv113 deleted the guestconn branch November 17, 2023 05:03
@afbjorklund
Copy link
Member

afbjorklund commented Nov 17, 2023

This seems to break connectivity on non-native and experimental drivers, due to missing directories.

Specified filename /dev/virtio-ports/io.lima-vm.guest_agent.0 does not exist.

It would have been nice if it had been backwards-compatible, to work with old agents and old drivers.

@AkihiroSuda
Copy link
Member

This seems to break connectivity on non-native and experimental drivers, due to missing directories.

Does this only affect #2000?
Instances created with an existing release are not affected IIUC?

@afbjorklund
Copy link
Member

afbjorklund commented Nov 17, 2023

As long as you have a working cidata/cloud-init and a regular driver, it should work (and was tested)

But I was able to restore the functionality, and also removed the ugly hardcoded paths in lima-guestagent

PR update is coming, but like so:

  •   sudo "${LIMA_CIDATA_GUEST_INSTALL_PREFIX}"/bin/lima-guestagent install-systemd --vsock-port "${LIMA_CIDATA_VSOCK_PORT}" --virtio-port "${LIMA_CIDATA_VIRTIO_PORT}"
    

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.

3 participants