Skip to content

Conversation

@vyasgun
Copy link
Member

@vyasgun vyasgun commented Dec 8, 2025

Use krun_add_vsock_port2() which accepts a listen parameter, enabling host-initiated vsock connections when listen=true.

Add support for 'connect' mode as default

Related issue: #79

Copy link
Member

@jakecorrenti jakecorrenti left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @vyasgun !

@vyasgun
Copy link
Member Author

vyasgun commented Dec 9, 2025

@jakecorrenti thanks for the review! I realised this PR inadvertently makes listen mode the default (due to missing the Connect action). I've added a follow-up commit that restores connect as the default behaviour when neither flag is specified.

@vyasgun vyasgun force-pushed the pr/vsock-listen branch 2 times, most recently from bd097c6 to 0f7a6ab Compare December 9, 2025 10:36
@jakecorrenti
Copy link
Member

jakecorrenti commented Dec 10, 2025

@jakecorrenti thanks for the review! I realised this PR inadvertently makes listen mode the default (due to missing the Connect action). I've added a follow-up commit that restores connect as the default behaviour when neither flag is specified.

Thanks for the follow up. I'll get around to re-reviewing and testing it tomorrow

Copy link
Member

@tylerfanelli tylerfanelli left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@jakecorrenti
Copy link
Member

jakecorrenti commented Dec 11, 2025

I'm having a little difficulty grokking this. Is the notion of what listen = true means different between libkrun and vfkit? In other words, listen = true for libkrun means the guest socket is listening for a connection from the host, but for vfkit listen = true means the host is listening for a socket connection from the guest? So this means that by passing the connect action to krunkit, we're doing the equivalent of the listen action in vfkit?

Use krun_add_vsock_port2() which accepts a listen parameter, enabling
host-initiated vsock connections when listen=true (set in connect mode).

Signed-off-by: Gunjan Vyas <vyasgun20@gmail.com>
@vyasgun
Copy link
Member Author

vyasgun commented Dec 13, 2025

Yes, you are correct. The listen=true in libkrun means initiating host to guest connections while listen mode in vfkit is guest to host connections. Updated the code to reflect this. (listen=false by default (listen mode)).

  • listen=true for host to guest direction (connect mode)
  • listen=false for guest to host direction (listen mode)

This handles the inverted flag meaning between vfkit and libkrun.

@jakecorrenti
Copy link
Member

Code seems fine but I'd like it if @slp took a look at this as well.

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