Skip to content

Conversation

@valpackett
Copy link
Contributor

@valpackett valpackett commented Oct 24, 2025

..yeah, you might say that this has really gone off the rails :) but we want to be able to ship apps with background services, configured the usual nix way just like on the host (which means systemd units are used to make them run).

Since containers/libkrun#424 libkrun can run a custom init as PID 1, so now we can run systemd. It turned out to be quite easy to "disaggregate" muvm-guest into separate services that systemd can manage.. well, separately. Here I made it work like a busybox-style "mega binary" where what it does depends on what it's called as (argv[0]). I haven't yet added all the services, but I've already included pwbridge here as an example of supporting socket activation.

muvm-systemd-pwb.av1.webm

fun fact: I only found #201 because I went to implement this. :) and I did replicate that feature in systemd:

[Unit]
OnFailure=exit.target
OnSuccess=exit.target

[Service]
Type=exec
ExecStart=/opt/bin/muvm-remote /run/current-system/sw/bin/bash
ExecStopPost=+/nix/store/i0g30z11viax2v3ynm3p1411c4dhi6w8-python3-3.12.10-env/bin/python -c "import os,fcntl,struct;fcntl.ioctl(os.open('/', os.O_RDONLY), 0x7602, int(os.getenv('EXIT_STATUS', '1')))"
User=appvm
Group=appvm
StandardError=tty
StandardInput=tty
StandardOutput=tty
TTYPath=/dev/hvc0

@valpackett
Copy link
Contributor Author

ping. any general feedback on this direction of work, on the changes currently on this branch?

@slp
Copy link
Collaborator

slp commented Nov 14, 2025

LGTM so far!

This is particularly useful for Nix, to avoid patching code when building.

Signed-off-by: Val Packett <[email protected]>
And use it for MUVM_UDEVD_PATH

Signed-off-by: Val Packett <[email protected]>
To remove the need for a sysctl binary.

Signed-off-by: Val Packett <[email protected]>
Signed-off-by: Val Packett <[email protected]>
Running x86_64 emulators on x86_64 is not typically desired, so only
try initializing them without flags on aarch64.

While here, let's call Box64 Box64 and not Box.

Signed-off-by: Val Packett <[email protected]>
Allow the user to replace muvm-guest with a custom init process. With
updated libkrun, it will even run as PID 1, making it possible to run
systemd.

Of course, this is not the suggested way to use muvm, but some use cases
necesitate the use of systemd. The next few commits will facilitate
running individual parts of muvm-guest as separate processes under a
custom service manager.

Signed-off-by: Val Packett <[email protected]>
…-network

To better support running under a custom service manager (e.g. systemd),
allow running individual functions of the guest binary when called with
distinct binary names.

Signed-off-by: Val Packett <[email protected]>
Support running the PipeWire bridge as a separate process, optionally
with systemd socket activation.

Signed-off-by: Val Packett <[email protected]>
This is how OnceLock is really meant to be used.. This will be helpful
for the custom init support, where various ways of starting the bridge
loop will be used.

Signed-off-by: Val Packett <[email protected]>
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