microvm.nix icon indicating copy to clipboard operation
microvm.nix copied to clipboard

Muvm as a target?

Open Mic92 opened this issue 1 month ago • 7 comments

We are currently optimizing performance of nixos running in muvm and have added quiet a few changes (some pending, some merged). TL;DR is that we are now under 500ms boot to app time with this code base: https://git.clan.lol/clan/munix

Now I have a different project where microvm is used, so it might become interesting to also add this to microvm.nix for some applications. @astro what do you generally thing about this idea?

Mic92 avatar Dec 05 '25 15:12 Mic92

Do you have any requirements on your side you want to see for such an integration.

Mic92 avatar Dec 05 '25 15:12 Mic92

I would like to have more control over virtio-{fs,block,net} than muvm seems to provide but a lib/runners/muvm.nix would not have to support the full range of options of the microvm module. No VMM other than qemu does that. :)

astro avatar Dec 07 '25 00:12 astro

Are there any general changes which every vmm would benefit from?

Also in my experience, just disabling payload and removing everything from a microvm decreases it's boot time significantly. Also switching from cloud hypervisor to qemu also did a good boost. Maybe we are using some settings wrong, why feedback there is welcome.

SuperSandro2000 avatar Dec 08 '25 03:12 SuperSandro2000

Most of the boot time optimization are not necessarily related to muvm only. We tuned a lot in systemd configuration to get time back i.e userborn and writing the activation in Rust.

However muvm has some unique features such as support for native context. This allows to share your host gpu with little overhead with a virtual machine. For headless VMs this might be for example useful for video encoding. Or you can have your browser inside a vm for extra security.

Mic92 avatar Dec 08 '25 06:12 Mic92

I would like to have more control over virtio-{fs,block,net} than muvm seems to provide but a lib/runners/muvm.nix would not have to support the full range of options of the microvm module. No VMM other than qemu does that. :)

I wasn't actually planning on porting our exact wrapper to microvm.nix. but a less opinionated version that is closer to the cli. Potentially replacing bubblewrap with a systemd chroot. I mainly pointed to the project because of our upstream patches to get everything to work. We still might have to wait a little to get all patches in to it. I.e. we added systemd support in https://github.com/AsahiLinux/muvm/pull/202

Mic92 avatar Dec 08 '25 06:12 Mic92

Sounds overall good to me

SuperSandro2000 avatar Dec 08 '25 09:12 SuperSandro2000

General optimizations should go into nixos-modules/microvm/optimization.nix from which users can opt out via microvm.optimize.enable = false;

astro avatar Dec 09 '25 03:12 astro