mirror of
https://github.com/vhaudiquet/ecrou.git
synced 2026-11-12 22:22:44 +00:00
51f56116a3fdc5e3b760db3ab3755aeb198340f4
The rootfs was a virtiofs share over an extracted tree, and that showed: the tree's owners were the host user's, because an unprivileged extract cannot chown to a tar's uid, and every chown inside the machine failed with EPERM against the host side. The rootfs crosses as a raw ext4 image now. mke2fs builds the cache image straight from the entry tarball (-d takes gz, xz and zst, and bakes each entry's recorded uid, gid and mode), the run copies it into a scratch directory with cp --reflink=auto --sparse=auto, and the engine attaches it with krun_add_disk + krun_set_root_disk_remount; the init blob mounts /dev/vda at / and chroots. The OCI layer bundle merges into one plain tar first, with whiteouts applied across layers and headers passed verbatim, so registry images keep their ownership too. Per-run provisioning rides debugfs: the generated init lands at /ecrou-init, the host resolver overwrites /etc/resolv.conf (unlink first - resolver-bearing images ship it as a symlink), a stale control file goes. The exit-code control file now outranks the machine child's exit code: with a block root the engine's exit-code channel (an ioctl through the virtiofs root device) never fires, so decode_status reads the file first and treats the child's code as machinery talk. Shell detection and the rare control-file read are debugfs stats, no extracted tree to walk. extract.rs keeps what the image build consumes (the tar decoder and the OCI merge) and drops the extraction-to-disk path it once carried; the module is private now. The engine needs the blk feature from here on: the snap and the CI engine build follow in their own commits.
ecrou
a small microVM runtime based on libkrun
Try ecrou in the terminal
Installation
ecrou is available as a strictly confined snap:
sudo snap install ecrou
sudo snap connect ecrou:kvm
Usage
$ ecrou run -it ubuntu
root@ecrou-vm-m2glhl:/#
Embed ecrou into your project
ecrou is both a library and a tiny CLI frontend around it. The library is embeddable into any project, allowing to use microVMs easily.
Rust
ecrou is a Rust library, which can just be called:
use ecrou::vm::RunOptions;
use ecrou::NoProgress;
fn main() -> ecrou::Result<std::process::ExitCode> {
let code = ecrou::vm::run(
&RunOptions {
image: "ubuntu:resolute".into(),
command: vec!["uname".into(), "-a".into()],
..RunOptions::default()
},
&NoProgress,
)?;
Ok(std::process::ExitCode::from(code.clamp(0, 255) as u8))
}
Languages
Rust
99.4%
Ruby
0.6%