Repository navigation
[WIP] feat(minimald): --gvproxy-bin flag + just recipes for #478 networking/VM bring-up #574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,3 +9,80 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||
| codesign-minvmd: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cargo build -p minvmd --release | ||||||||||||||||||||||||||||||||||||||||||||||||||
| codesign --entitlements crates/minvmd/minvmd.entitlements --force -s - target/release/minvmd | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # --- Networking / VM bring-up (epic #478) --------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| # Lane A = native minimald on the host (DM2). Lane B = minvmd microVM (DM1, KVM). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| # These recipes mirror the CI lanes (.github/workflows/ci-netns.yml and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| # ci-linux-kvm.yml) so a dev reproduces them locally with one command each. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| # Lane A needs passwordless sudo; Lane B needs /dev/kvm (see `setup-kvm-group`). | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # Host arch, used to name guest artifacts and the musl target. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| # Override per-invocation: `just arch=x86_64 setup-minvmd`. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| arch := `uname -m` | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # libkrun runtime/link prefix for Lane B. Override with the KRUN_PREFIX env var. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| krun_prefix := env_var_or_default("KRUN_PREFIX", env_var("HOME") / ".krun") | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # Fetch the pinned gvproxy switch binary into .scratch/ (no sudo, no install). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| fetch-gvproxy: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| @mkdir -p .scratch | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ./scripts/fetch-gvproxy.sh .scratch/gvproxy | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # Lane A — netns proofs: UC1 (no-net refuses egress) + UC6 (PTask-to-PTask). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| test-netns: fetch-gvproxy | ||||||||||||||||||||||||||||||||||||||||||||||||||
| MINIMALD_NETNS_TEST=1 GVPROXY_BIN="{{justfile_directory()}}/.scratch/gvproxy" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cargo test -p minimald -p sandbox2 -p minimald-rpc netns -- --include-ignored --nocapture | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # Lane A — UC7 WireGuard mesh netns proof (builds unprivileged, runs as root). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| test-mesh-netns: fetch-gvproxy | ||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||
| bin=$(cargo test -p minimald --features networking-wg --test mesh_uc7 \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| --no-run --message-format=json \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| | jq -r 'select(.executable != null and (.target.name? == "mesh_uc7")) | .executable' \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| | tail -1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "mesh_uc7 binary: $bin" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| sudo -E MINIMALD_NETNS_TEST=1 GVPROXY_BIN="$PWD/.scratch/gvproxy" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "$bin" --include-ignored --nocapture | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # Lane A — networking feature unit suites (networking-wg + networking-proxy). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| test-net-features: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cargo test -p minimald --features networking-wg | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cargo test -p minimald --features networking-proxy | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # Lane A — netns proofs + mesh proof + feature suites. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| test-net-lane-a: test-netns test-mesh-netns test-net-features | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # Lane B — one-time setup: fetch libkrun + guest kernel/rootfs, build initramfs. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| # build-initramfs.sh uses `cross` (Docker); on a native-arch host you can skip | ||||||||||||||||||||||||||||||||||||||||||||||||||
| # Docker — see crates/minvmd/README.md ("No Docker?") for the musl-gcc path. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| setup-minvmd: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| @mkdir -p .scratch | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ./scripts/fetch-libkrun.sh "{{krun_prefix}}" "{{arch}}" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ./scripts/fetch-artifact.sh virtio-kernel .scratch/vmlinuz "{{arch}}" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ./scripts/fetch-artifact.sh minvmd-rootfs .scratch/rootfs.img "{{arch}}" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ./scripts/build-initramfs.sh .scratch/initramfs.cpio "{{arch}}-unknown-linux-musl" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # Lane B — minvmd VM E2E: boot READY round-trip + session command over the bridge. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| test-minvmd-e2e: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||
| krun="{{krun_prefix}}" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| common="LIBKRUN_PREFIX=$krun LD_LIBRARY_PATH=$krun MINVMD_E2E=1 \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| MINVMD_KERNEL_PATH=$PWD/.scratch/vmlinuz \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| MINVMD_ROOTFS_PATH=$PWD/.scratch/rootfs.img \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| MINVMD_INITRAMFS=$PWD/.scratch/initramfs.cpio" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| sg kvm -c "env $common MINVMD_BOOT_LOG=$PWD/.scratch/boot-e2e.log \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cargo test -p minvmd --test boot_e2e -- --include-ignored --nocapture" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| sg kvm -c "env $common \ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cargo test -p minvmd --test minimald_session_e2e -- --include-ignored --nocapture --exact minimald_exec_over_bridge" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+68
to
+80
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
On a clean repo, this recipe can fail because Suggested patch-test-minvmd-e2e:
+test-minvmd-e2e: setup-minvmd
#!/usr/bin/env bash
set -euo pipefail📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| # Lane B — print the one-time `sudo usermod -aG kvm` step (durable /dev/kvm access). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| setup-kvm-group: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| @echo "Run once, then re-login (or prefix VM commands with 'sg kvm -c ...'):" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| @echo " sudo usermod -aG kvm $USER" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| # Run a native minimald (DM2) foreground, OwnIp switch -> fetched gvproxy (no install). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| run-minimald *ARGS: fetch-gvproxy | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cargo run -p minimald -- run --gvproxy-bin "{{justfile_directory()}}/.scratch/gvproxy" {{ARGS}} | ||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Guard against empty
mesh_uc7executable resolution beforesudoexecution.If the JSON filter returns nothing,
"$bin"is empty and the recipe fails with a non-actionable error. Add an explicit check with a clear message.Suggested patch
bin=$(cargo test -p minimald --features networking-wg --test mesh_uc7 \ --no-run --message-format=json \ | jq -r 'select(.executable != null and (.target.name? == "mesh_uc7")) | .executable' \ | tail -1) + if [[ -z "${bin:-}" ]]; then + echo "mesh_uc7 executable not found; cargo test --no-run did not emit a binary path" >&2 + exit 1 + fi echo "mesh_uc7 binary: $bin"📝 Committable suggestion
🤖 Prompt for AI Agents