Commit 6584e0c
feat(vz-backend): Phase 2 Day 4 — codesign helper, vm-debug boot, first-boot attempt
Ship the local-dev codesign helper that bestows
`com.apple.security.virtualization` on a `cargo build`
`elastos` binary so Apple's `VZVirtualMachineConfiguration.validateWithError`
accepts it, unblocking the Day 3 lifecycle wiring. Add
`elastos vm-debug boot --rootfs … --kernel …` so a Mac dev can
drive the Day 3 path end-to-end (load → start → wait for Ctrl-C
or guest-stop → stop) and stream guest kernel printk to stdout
via the existing `vm_console` tracing target.
New files:
- scripts/dev/sign-elastos-vz/sign.sh — idempotent macOS-only
ad-hoc signer (`codesign --force --sign - --entitlements …`).
Refuses to run off macOS, verifies the entitlement landed
before exiting 0, supports `--verify-only` for inspection.
- scripts/dev/sign-elastos-vz/vz.entitlements.plist — minimal
entitlements plist granting one key:
`com.apple.security.virtualization`. Single source of truth.
- scripts/dev/sign-elastos-vz/README.md — one-page operator
guide: why, how, what NOT to expect (no notarization, no
developer cert).
- elastos/crates/elastos-server/src/vm_debug_cmd.rs — clap
`VmDebugCommand::Boot` handler. Validates inputs (rootfs +
kernel exist, memory >= 64 MiB, vcpus >= 1), stages a
tempdir capsule layout (hard-link rootfs in, fall back to
copy), synthesises a minimal `CapsuleManifest` with the
Vz-mandated boot args, calls `VzProvider::load`/`start`,
races `tokio::signal::ctrl_c()` against polled
`provider.status` so the CLI exits cleanly whether the user
Ctrl-Cs or the guest halts itself. macOS-only impl; Linux
fall-through returns a typed "see docs/MAC.md" error.
- docs/vz-backend/PHASE_2_DAY_4_NOTES.md — verbatim outcome
log of the first-boot attempt on this dev machine.
Touched files:
- elastos/crates/elastos-server/src/main.rs —
`Commands::VmDebug(VmDebugCommand)` added; dispatch arm hands
off to `vm_debug_cmd::run`. The `EnvFilter` is widened by one
additive directive (`vm_console=info`) so guest-kernel printk
from BOTH the crosvm and Vz backends is visible without
forcing operators to set `RUST_LOG`. `RUST_LOG` still
overrides.
- docs/MAC.md — appends the "First boot on Apple Silicon"
operator recipe and the kernel-artifact note.
End-to-end attempt on macOS 26.4.1 / Apple Silicon (full output
in PHASE_2_DAY_4_NOTES.md):
1. cargo build, sign, --verify-only — all clean.
2. `vm-debug boot` with stand-in artifacts reached
`provider.load` and `provider.start` cleanly. Apple's Vz
framework returned its expected "Internal Virtualization
error. The virtual machine failed to start." because the
stand-in kernel is 18 bytes. **Day 4 contract met: the
wiring is end-to-end correct on a signed binary; only a
real arm64 Linux Image + rootfs is missing for actual
guest boot. That artifact procurement is Day 5.**
3. The Day 3 `ENTITLEMENT_HINT` message did NOT appear, which
is the regression target — it should appear only on
unsigned binaries. Apple Silicon's hard signing requirement
means we can't easily run an unsigned binary on this host
to verify the negative case, but the pure-string Day 3 unit
tests (`format_validate_error_embeds_day_4_hint_…`) cover
the contract deterministically.
Tests added (5; all pass locally):
- vm_debug_cmd::tests::validate_boot_inputs_rejects_missing_rootfs
- vm_debug_cmd::tests::validate_boot_inputs_rejects_missing_kernel
- vm_debug_cmd::tests::validate_boot_inputs_rejects_tiny_memory
- vm_debug_cmd::tests::validate_boot_inputs_rejects_zero_vcpus
- vm_debug_cmd::tests::build_staging_layout_creates_capsule_dir_with_entrypoint_rootfs
Plus one cfg-gated Linux-only test
(`vm_debug_boot_on_non_macos_returns_typed_error_pointing_at_docs`)
which CI will exercise.
Gates re-run locally:
- cargo build --workspace
- cargo test -p elastos-vz (69 green)
- cargo test -p elastos-server --bin elastos vm_debug (5 green)
- cargo clippy -p elastos-vz -p elastos-server --all-targets -- -D warnings
- cargo fmt --check
- scripts/check-linux-untouched.sh bcf5a0a (gate OK)
- scripts/dev/mac-vz-feature-check probe (still exit 0; validate
line still SKIPs because the probe is its own unsigned binary)
Pre-existing failures in `elastos-server::setup::tests::*`
(3 tests around vmlinux platform-entry lookup for darwin-arm64)
are unrelated to Day 4 — verified by running them on the prior
commit (2994515) where they also fail. They belong to the
upstream darwin-runtime setup work, not the Vz backend, and
are outside this commit's scope.
Day 4 does NOT include:
- VZVirtualMachineDelegate (Day 5+)
- shipping a vmlinux artifact in the repo (kernel procurement
is Day 5)
- production notarization / distribution signing (Phase 6)
- touching the four Linux-untouched protected crates
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 2994515 commit 6584e0c
7 files changed
Lines changed: 867 additions & 1 deletion
File tree
- docs
- vz-backend
- elastos/crates/elastos-server/src
- scripts/dev/sign-elastos-vz
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
143 | 189 | | |
144 | 190 | | |
145 | 191 | | |
| 192 | + | |
| 193 | + | |
146 | 194 | | |
147 | 195 | | |
148 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
491 | 492 | | |
492 | 493 | | |
493 | 494 | | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
494 | 501 | | |
495 | 502 | | |
496 | 503 | | |
| |||
1025 | 1032 | | |
1026 | 1033 | | |
1027 | 1034 | | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
1028 | 1042 | | |
1029 | 1043 | | |
1030 | 1044 | | |
1031 | 1045 | | |
1032 | | - | |
| 1046 | + | |
| 1047 | + | |
1033 | 1048 | | |
1034 | 1049 | | |
1035 | 1050 | | |
| |||
1078 | 1093 | | |
1079 | 1094 | | |
1080 | 1095 | | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
1081 | 1104 | | |
1082 | 1105 | | |
1083 | 1106 | | |
| |||
0 commit comments