Skip to content

krun: start render server if required - #2235

Open
slp wants to merge 1 commit into
containers:mainfrom
slp:virglrenderer-from-host
Open

slp wants to merge 1 commit into
containers:mainfrom
slp:virglrenderer-from-host

Conversation

@slp

@slp slp commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

So far, when VIRGLRENDERER_RENDER_SERVER was specified in gpu_flags, we
where using the /usr/libexec/virgl_render_server binary from the OCI.
It was started by the host's libvirglrenderer library (linked from
libkrun and, as such, running in the container's context) when the
virtio-gpu device was initialized.

This is convenient, because it allows the OCI to pack both the binary
and the libraries the render server requires, but meant running an
OCI-provided binary outside the microVM (but still within the container
context).

In 1.19.5, libkrun introduces the ability to provide a file descriptor
for an already running render server, allowing us to start the render
server ourselves.

This is still tricky, because we need to start the render server from a
context where it still has access to the host's vulkan libraries and
icds, but most distributions ship a virgl_render_server without
self-isolating capabilities, and we don't want to a render server
listening to guests commands and still having access to the whole host's
filesystem.

To address this, we run virgl_render_server through bwrap, which
provides a reasonable degree of isolation for this use case. Both
binaries must be present in the system for the render server to be
started. If either is missing, a descriptive error is returned to the
user.

For security reasons, instead of being backwards compatible, if an older
version of libkrun is present in the system, we reject enabling GPU
access.

@slp

slp commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

With this change, virgl_render_server is run from the host but inside the container context, just as we do with passt. This may pose some challenges with selinux, as in Fedora I need to run the container with --security-opt label=disable. But that's a problem at the distro level and not something we can't fix here.

The only thing we could do is running virgl_render_server outside the container context, but I'm honestly not comfortable proposing such option.

The latest iteration of this PR uses bwrap to run virgl_render_server still in the host context, but reasonably isolated.

@slp
slp marked this pull request as draft September 9, 2026 16:20

@giuseppe giuseppe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am fine with this, LGTM

is it still a Draft?

@slp

slp commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

is it still a Draft?

Yes, we're rewriting so it's crun the one starting virgl_render_server. I'll update the PR later today.

@slp
slp force-pushed the virglrenderer-from-host branch from 828f161 to e70cb7f Compare September 10, 2026 14:10
So far, when VIRGLRENDERER_RENDER_SERVER was specified in gpu_flags, we
where using the /usr/libexec/virgl_render_server binary from the OCI.
It was started by the host's libvirglrenderer library (linked from
libkrun and, as such, running in the container's context) when the
virtio-gpu device was initialized.

This is convenient, because it allows the OCI to pack both the binary
and the libraries the render server requires, but meant running an
OCI-provided binary outside the microVM (but still within the container
context).

In 1.19.5, libkrun introduces the ability to provide a file descriptor
for an already running render server, allowing us to start the render
server ourselves.

This is still tricky, because we need to start the render server from a
context where it still has access to the host's vulkan libraries and
icds, but most distributions ship a virgl_render_server without
self-isolating capabilities, and we don't want to a render server
listening to guests commands and still having access to the whole host's
filesystem.

To address this, we run virgl_render_server through bwrap, which
provides a reasonable degree of isolation for this use case. Both
binaries must be present in the system for the render server to be
started. If either is missing, a descriptive error is returned to the
user.

For security reasons, instead of being backwards compatible, if an older
version of libkrun is present in the system, we reject enabling GPU
access.

Signed-off-by: Sergio Lopez <[email protected]>
@slp
slp force-pushed the virglrenderer-from-host branch from e70cb7f to 9222b78 Compare September 10, 2026 14:14
@slp slp changed the title krun: use virgl_render_server from host krun: start render server if required Sep 10, 2026
@slp
slp marked this pull request as ready for review September 14, 2026 09:51
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