libkrun: when you want a VM but your users want a container
By Origin Clouds Engineering, Platform team
Most VMMs are programs you run and talk to. libkrun is a library you link against. Your program calls a few functions to describe a VM (CPUs, memory, a root filesystem, a command) and then hands its own process over to become that VM. The guest kernel ships as another library, libkrunfw, so there's no separate kernel image to manage.
Why that matters
- Container tools can add a VM boundary without a separate hypervisor daemon
- The device model is small: virtio-fs for the filesystem, vsock, a console and networking
- It runs on KVM on Linux and on Hypervisor.framework on Apple Silicon Macs, with the same API
Tools built on it
krunvm creates microVMs straight from OCI images, so a container image becomes a bootable VM in one step.
krunvm create docker.io/library/fedora --name dev --cpus 2 --mem 2048
krunvm start devcrun, the OCI runtime used by Podman, can be built with libkrun support. When it is, invoking it as krun runs each container inside its own lightweight VM, with no change to the image.
# requires crun built with libkrun and the 'krun' runtime configured
podman run --runtime krun --rm -it docker.io/library/alpine shWhere it fits, and where it doesn't
libkrun shines when isolation should be invisible: a developer tool, a build step, a plugin system that runs third-party code. It is not trying to be a general-purpose hypervisor. If you need Windows guests, live migration or PCI passthrough, use QEMU/KVM. If you need thousands of tenant VMs managed by an orchestrator, Firecracker's API-driven model is usually a better fit.
Because the VMM lives in your process, its resource limits and lifecycle are your process's. Plan cgroups and supervision the same way you would for the workload itself.
Running this in production?
We help teams design, harden and tune platforms like this one.
Talk to an engineer
Origin Clouds