|
| 1 | +# Experimental mkosi backend |
| 2 | + |
| 3 | +This is a deliberately small Debian/mkosi implementation of the dstack guest |
| 4 | +OS. It is an experiment, not yet a replacement for the release Yocto backend. |
| 5 | +It tracks the Yocto image's confidential-computing, container, storage, |
| 6 | +network, TPM, SSH, chrony and dstack guest-service capabilities. |
| 7 | + |
| 8 | +## Reproducibility model |
| 9 | + |
| 10 | +`versions.env` pins the stable 7.x kernel tarball by SHA-256 and selects an |
| 11 | +immutable Debian snapshot. `Cargo.lock`, `--locked --offline`, a fixed |
| 12 | +`SOURCE_DATE_EPOCH`, normalized file mtimes, fixed kernel build identity and |
| 13 | +mkosi's deterministic image construction close the remaining inputs. The two |
| 14 | +dstack binaries therefore require an already populated Cargo cache; use a |
| 15 | +vendored source tree in hermetic CI. `DSTACK_SKIP_RUST=1` exists only for |
| 16 | +rootfs/kernel development and does **not** produce a functional guest. |
| 17 | + |
| 18 | +The custom kernel starts from `x86_64_defconfig`, then applies the reviewed |
| 19 | +`kernel.config` fragment. This is the practical upstream equivalent of Yocto's |
| 20 | +`linux-yocto-tiny` plus explicit features: disabling arbitrary defconfig |
| 21 | +symbols without resolving Kconfig dependencies would be less auditable. Both |
| 22 | +the TDX DMA patch and the ACPI BadAML/SystemMemory sandbox patch are reused |
| 23 | +verbatim from `meta-dstack`; patch fuzz is forbidden. The final `.config` is |
| 24 | +checked before compilation. |
| 25 | + |
| 26 | +## Build and acceptance |
| 27 | + |
| 28 | +Host requirements include mkosi >= 26, systemd tools, a C/Rust kernel and EDK2 |
| 29 | +build toolchain, `bc`, `bison`, `flex`, `nasm`, `iasl`, OpenSSL/ELF/UUID |
| 30 | +development headers, `patch`, `pax-utils` (`lddtree`), `squashfs-tools`, |
| 31 | +`cryptsetup`, `gdisk`, `dosfstools`, `mtools`, `curl`, `xz`, QEMU/KVM and root |
| 32 | +privileges (or a working user namespace). Full UKI release assembly also needs |
| 33 | +the pinned `nitro-tpm-pcr-compute` described by `os/image/assemble.sh`. |
| 34 | + |
| 35 | +```sh |
| 36 | +./os/mkosi/build.sh lint |
| 37 | +./os/build.sh --backend mkosi --build-dir "$PWD/os/mkosi/build" |
| 38 | +./os/mkosi/build.sh repro-check "$PWD/os/mkosi/repro" |
| 39 | +# QEMU smoke-test the assembled UKI disk (host OVMF path is distro-specific) |
| 40 | +qemu-system-x86_64 -machine q35 -m 2G -nographic \ |
| 41 | + -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE_4M.fd \ |
| 42 | + -drive if=virtio,format=raw,file=os/mkosi/build/out/prod/dstack-0.6.0/disk.raw |
| 43 | +``` |
| 44 | + |
| 45 | +Acceptance means: the static contract passes; a disk with systemd-boot/UKI |
| 46 | +boots on x86_64 QEMU; `/proc/config.gz` contains the checked TDX/SNP, TPM, |
| 47 | +ACPI, dm-verity/crypt, virtio, container and hardening options; dstack services |
| 48 | +are enabled; and two clean builds compare byte-for-byte. The backend exports |
| 49 | +artifact-manifest schema v1 and delegates final assembly to |
| 50 | +`os/image/assemble.sh`, exactly like Yocto. Its output contains the same |
| 51 | +`dstack-0.6.0/` directory, bare-metal and UKI tarballs, partitioned combined |
| 52 | +squashfs/dm-verity image, metadata, measurements, checksums, kernel, initramfs, |
| 53 | +OVMF and UKI. Package contents differ because this backend uses Debian, but |
| 54 | +consumers see the same release format and partition labels. |
| 55 | + |
| 56 | +The firmware is not Debian's generic OVMF: `build-ovmf.sh` builds the same |
| 57 | +EDK2 stable-202502 revision and `pre202505` TDX measurement layout selected by |
| 58 | +the Yocto recipe. A generic OVMF cannot be substituted because `dstack-mr` |
| 59 | +would produce invalid or unparseable TDX measurement material. |
0 commit comments