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

krunkit libkrun virglrenderer: new ports #27208

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

tsujp
Copy link
Contributor

@tsujp tsujp commented Dec 26, 2024

Description

Three (3) new ports:

  1. krunkit
  2. libkrun
  3. slp's fork of virglrenderer with required patches for libkrun since these are not merged into virglrenderer upstream.

krunkit allows running VMs on macOS using Hypervisor.framework with hardware accelerated graphics using Venus.

Podman can also use krunkit as a driver instead of the default applehv (Virtualization.framework). If you configure Podman to use krunkit you can run hardware accelerated graphics workloads within the VM (and thus containers) Podman manages on your macOS hosts.

libkrun allows use of more modern versions of virtio and has some advanced networking features (although the latter is not enabled by default nor available at all as I cannot be bothered).

There are a few questions I have regarding this:

  1. I plan to add a libkrun variant to the Podman port, this would simply add krunkit as a runtime dependency. Strictly speaking uninstalling krunkit would not break Podman as Podman executes the binary krunkit when configured to use it. It does feel nicer to be able to install Podman with krunkit in one go though. Shall I add said variant?
  2. The version of virglrenderer here is slp's fork as already mentioned. Would you prefer I change the Portfile to use upstream virglrenderer and add a libkrun variant to virglrenderer which uses slp's or shall we leave the Portfile as-is only use slp's for now? In the former case how does one specify a variant in build_run?

Once those questions have answers I can do some final cleanup on the Portfiles (as I've left the TODOs in so I do not forget).

Type(s)
  • bugfix
  • enhancement
  • security fix
Tested on

macOS 14.5 23F79 arm64
Xcode 16.0 16A242d

Verification

Have you

Copy link
Contributor

@reneeotten reneeotten 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 the submissions @tsujp. I've left a few comments, they apply to all ports.

Also, each ports should be in a different commit please.

emulators/krunkit/Portfile Outdated Show resolved Hide resolved
emulators/krunkit/Portfile Outdated Show resolved Hide resolved
emulators/krunkit/Portfile Show resolved Hide resolved
emulators/krunkit/Portfile Outdated Show resolved Hide resolved
emulators/krunkit/Portfile Outdated Show resolved Hide resolved
emulators/libkrun/Portfile Outdated Show resolved Hide resolved
@tsujp tsujp requested a review from reneeotten December 26, 2024 17:41
@tsujp
Copy link
Contributor Author

tsujp commented Dec 26, 2024

thanks for the submissions @tsujp. I've left a few comments, they apply to all ports.

Also, each ports should be in a different commit please.

Changes made; requested re-review.

@tsujp
Copy link
Contributor Author

tsujp commented Dec 26, 2024

I note that sudo port -vst install krunkit does not work (the -t trace flag is the culprit), but sudo port -vs install krunkit works fine.

It fails around extracting virglrenderer (as of course it prompts to install dependencies). I'm very tired right now so I'm not sure why or if it's actually important?

sudo port -vs install krunkit installs krunkit, libkrun, and virglrenderer fine and Podman can correctly use krunkit and there appears to be the graphics drivers in the VM at /dev/dri which indicates all is working.

@tsujp
Copy link
Contributor Author

tsujp commented Jan 8, 2025

Small bump @reneeotten are you able to re-review?

@neverpanic
Copy link
Member

It fails around extracting virglrenderer (as of course it prompts to install dependencies). I'm very tired right now so I'm not sure why or if it's actually important?

That's expected, trace mode is broken on arm64. See https://trac.macports.org/ticket/66358.

In general this looks good. Let me know what whether you want to change something in response to my comments. Meanwhile, I'll give this a test with trace mode on my machine (where I have a working setup with some magic that's not quite production-ready).

emulators/libkrun/Portfile Outdated Show resolved Hide resolved
emulators/libkrun/Portfile Outdated Show resolved Hide resolved
emulators/libkrun/files/patch-makefile.diff Show resolved Hide resolved
emulators/krunkit/files/patch-makefile.diff Show resolved Hide resolved
Comment on lines 37 to 38
depends_run port:libepoxy \
port:moltenvk
Copy link
Member

Choose a reason for hiding this comment

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

Both of these are required at build time and runtime, so they should be depends_lib.

Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

depends_run changed to depends_lib.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

virglrenderer still fails to find moltenvk if the rpath patch from krunkit is removed.

emulators/libkrun/Portfile Outdated Show resolved Hide resolved
emulators/krunkit/Portfile Outdated Show resolved Hide resolved
@neverpanic
Copy link
Member

With my suggested changes applied, I can report that this works as expected:

$ export CONTAINERS_MACHINE_PROVIDER=libkrun
$ podman machine init --cpus 6 --memory 8192 --now
[…]
$ podman machine ssh podman-machine-default ls -lash /dev/dri
total 0
0 drwxr-xr-x.  3 root root        100 Jan 17 16:15 .
0 drwxr-xr-x. 16 root root       3.7K Jan 17 16:15 ..
0 drwxr-xr-x.  2 root root         80 Jan 17 16:15 by-path
0 crw-rw----.  1 root video  226,   0 Jan 17 16:15 card0
0 crw-rw-rw-.  1 root render 226, 128 Jan 17 16:15 renderD128

@tsujp
Copy link
Contributor Author

tsujp commented Jan 18, 2025

With my suggested changes applied, I can report that this works as expected:

$ export CONTAINERS_MACHINE_PROVIDER=libkrun
$ podman machine init --cpus 6 --memory 8192 --now
[…]
$ podman machine ssh podman-machine-default ls -lash /dev/dri
total 0
0 drwxr-xr-x.  3 root root        100 Jan 17 16:15 .
0 drwxr-xr-x. 16 root root       3.7K Jan 17 16:15 ..
0 drwxr-xr-x.  2 root root         80 Jan 17 16:15 by-path
0 crw-rw----.  1 root video  226,   0 Jan 17 16:15 card0
0 crw-rw-rw-.  1 root render 226, 128 Jan 17 16:15 renderD128

Since I added c0defa8 it appeared to build correctly in MacPorts CI so it's curious something was missing (or it still built but with a warning and I missed it). In any case thanks for the review and additional confirmation.

Copy link
Contributor

@reneeotten reneeotten left a comment

Choose a reason for hiding this comment

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

also please check these are the latest upstream versions - the PR is quite old and perhaps upstream has released again?

Also, please make the changes @neverpanic requested.

@tsujp
Copy link
Contributor Author

tsujp commented Feb 9, 2025

On it now.

  • Update libkrun
    • libkrun version check
    • Portfile changes
  • Update krunkit
    • krunkit version check
    • Portfile changes
  • Update virglrenderer
    • virglrenderer version check
    • Portfile changes
  • PR changes with build (-vs) succeed locally

@tsujp
Copy link
Contributor Author

tsujp commented Feb 9, 2025

@neverpanic @reneeotten changed made, please re-review.

@tsujp
Copy link
Contributor Author

tsujp commented Feb 9, 2025

Even with depends_lib change:

$ otool -L $(which -a krunkit)
/opt/local/bin/krunkit:
        /opt/local/lib/libkrun-efi.dylib (compatibility version 0.0.0, current version 0.0.0)

krunkit still functions correctly (output has always been 0.0.0, I've never seen it have libkrun-efi's actual version number there).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants