Skip to content

Conversation

@mtjhrc
Copy link
Collaborator

@mtjhrc mtjhrc commented Dec 10, 2025

Not sure if this is the API we want to go with , we should have some way to control TSI and vsock.

@mtjhrc
Copy link
Collaborator Author

mtjhrc commented Dec 10, 2025

@slp After containers/libkrunfw#106 we don't enable UNIX hijacking in libkrun implicitly by default. Should I restore that behavior and enable it?

@mtjhrc mtjhrc force-pushed the explicit-vsock-api branch from 1ca7f4c to 46bd3e2 Compare December 15, 2025 15:46
@slp
Copy link
Collaborator

slp commented Dec 15, 2025

@mtjhrc this is looking good, what's missing to be ready for review?

@mtjhrc mtjhrc force-pushed the explicit-vsock-api branch 2 times, most recently from a9a286d to 36827ac Compare December 17, 2025 13:23
@mtjhrc mtjhrc marked this pull request as ready for review December 17, 2025 13:31
Refactor the vsock device to explicitly configure usage of INET and UNIX
proxies.
This also removes the heuristic that enabled unix socket hijacking if "/" is
the rootfs. This got broken anyways with the new libkrunfw, which now also
requires a kernel argument for hijacking unix sockets.

Add new public API functions for explicit vsock control:
- krun_disable_implicit_vsock(): Disable the implicit vsock device
- krun_add_vsock(): Add vsock with explicit TSI feature flags

krun_add_vsock() requires krun_disable_implicit_vsock() to be called
first, otherwise an error is returned - we only support 1 vsock device.

Add a check in krun_set_port_map() and krun_add_vsock_port() to ensure vsock is
enabled.

Signed-off-by: Matej Hrica <[email protected]>
@mtjhrc mtjhrc force-pushed the explicit-vsock-api branch from 36827ac to 6a4dbc6 Compare December 17, 2025 13:40
@mtjhrc
Copy link
Collaborator Author

mtjhrc commented Dec 17, 2025

Note, this PR also removes the heuristic that enabled unix socket hijacking if "/" is the rootfs. This got broken anyways with the new libkrunfw, which now requires a kernel argument for hijacking unix sockets.

*
* By default, libkrun creates a vsock device implicitly with TSI hijacking
* enabled based on heuristics. Calling this function overrides the implicit
* behavior and explicitly configures the vsock device.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The comment above seems to point that calling this function will automatically disable the implicit vsock, but that's not what happens. Calling this one without calling krun_disable_implicit_vsock() first will lead to [libcrun:krun]: could not add vsock configuration: File exists.

I think we need to either have this function also disable the implicit vsock, or clarify that krun_disable_implicit_vsock() needs to be called first.

@slp
Copy link
Collaborator

slp commented Dec 19, 2025

Tested with crun and found no regressions. Also, enabling TSI_UNIX from crun does make unix sockets to work, as expected.

I've only have a minor complain explained in a comment, otherwise LGTM.

Copy link
Collaborator

@slp slp left a comment

Choose a reason for hiding this comment

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

Please take a look at the comment about disabling the implicit vsock.

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.

2 participants