Repository navigation
feat :: __vm-run runs a command under a virtual CPU that presents an EESSI target - #452
Merged
Merged
Conversation
An internal helper. --mode kvm boots the host kernel under QEMU with a named CPU model and enforce, the host root shared read-only over virtiofs; --mode tcg runs the command in qemu user mode for a target of another architecture. The guest checks archdetect, archspec, gcc -march=native, the vendor and /dev/fd before the command starts, and the helper refuses when one does not name the target.
…no test is skipped
…smatch, test the helper call
…extensions GCC appends
…eck before the build The zlib.net download intermittently handed the GitHub runner a file that failed EasyBuild's checksum (PRs 450, 451 and 452); the same URL gives the expected sha256 elsewhere. The job fetches it with retries, checks the sha256, and places it in eb-local's source path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat ::
__vm-runruns a command under a virtual CPU that presents an EESSI targetBase:
develop. Last of three PRs that merge in this order:feat/isa-audit,feat/cpu-target,feat/cpu-target-vm(this one). The branch containsdevelop,feat/isa-auditandfeat/cpu-target, so once those two have merged this PR shows only the helper and the glue below. It merges without conflicts after them.An internal helper, absent from
--help, for the builds that mask the CPU view:COMMAND runs in the caller's working directory, as the caller's uid and groups, with the EasyBuild and EESSI variables, and its exit status is the helper's.
kvm: QEMU with KVM boots the host kernel with the host root read-only over virtiofs,/cvmfs/software.eessi.ioshared, and the working directory,HOMEand the build directories named byEASYBUILD_*andEESSI_*_INSTALLwritable. The CPU is a named model plus the corrections measured for it (Genoa:flush-l1d,la57=off,pcid=off, the SRSO and TSA bits,tsc-deadline; Intel models:vendor=GenuineInteland the non-ISA bits off) withenforce. No path uses-cpu host.tcg: for a target of the other architecture, qemu user mode withQEMU_CPU=<model>on the EESSI compatibility layer. Without abinfmt_miscentry the helper registers the emulator in a user and mount namespace of its own.gcc -march=native(-mcpu=nativeon aarch64), archspec and/dev/fdall name the target, and the helper refuses otherwise.enforcerefusal included); 126 the CPU view does not name the target.PATHorEB_LOCAL_QEMU_DIRandEB_LOCAL_VIRTIOFSD;EB_LOCAL_VM_KERNEL,EB_LOCAL_VM_DIR,EB_LOCAL_VM_KEEP,EB_LOCAL_VM_CVMFS_REPOSandEB_LOCAL_VM_GCCare documented in the environment reference.Code is in
src/vm.zigandsrc/vm/*.sh;main.ziggets the dispatch and a_ = vm;in the test block. Docs: a section in the command reference marked internal,howto/build-under-qemu, the environment variables, and a changelog fragment.Tests
tests/test_vm_run.py: the refusals run everywhere. The VM runs exist only withEB_LOCAL_VM_TESTS=1, because GitHub-hosted runners do not offer nested KVM in general; without it they are not defined, so the zero-skip job sees no skipped test.develop, none added.Measured on the build host (Ryzen 9 9950X, QEMU 11.1.2, EESSI 2026.06, 8 vCPUs, host under load), start to exit including the checks:
x86_64/amd/zen4znver4, archdetectx86_64/amd/zen4, archspeczen4, vendorAuthenticAMD; exit status 7 passes throughx86_64/intel/icelakeicelake-server, archspecicelake,GenuineIntelaarch64/neoverse_n1aarch64/neoverse_n1, gccneoverse-n1, a C compile and run insidex86_64/intel/sapphirerapidsenforcerefuses the model on this hostx86_64/amd/zen4, bad compilerqemu user mode answers
/proc/cpuinfoitself with the model's CPU part, so archdetect and GCC readneoverse_n1. Its feature line lacksevtstrm, the one feature archspec 0.2.5 needs forneoverse_n1that is missing, so archspec readsaarch64and the helper refuses with 126 unless--allow-archspec-mismatchis given (stderr then carries a warning).How
--cpu-target --mask kvm|tcgcalls it--mask kvmand--mask tcg(fromfeat/cpu-target) build with this prefix in front of the build command:vmPrefixinmain.zigbuilds that argument list, with a unit test of the words for both modes and for the opt-in.The helper is dispatched before argument parsing and is not a
Command, so--cpu-targetfinds it through the program's own build (the lookup by command name infeat/cpu-targetnever finds a hidden helper).Statuses 2, 125 and 126 print a message that names the route and the target: a refused request, a virtual machine that did not run (console log named in the lines above), and a guest CPU that did not read as the target. A status of the build command itself passes through unchanged.
--mask-allow-archspec-mismatch(documented in the command reference) passes--allow-archspec-mismatchand setsEB_LOCAL_ALLOW_ARCHSPEC=1for the preflight inside the guest, which then accepts an archspec name other than the target's and still refuses on every other check. An aarch64--mask tcgbuild needs it; the option is an error on thecpuidroute. Without it the tcg build stops with status 126 and says which option accepts the name.Inside the guest the preflight reads the CPU vendor from
/proc/cpuinfo(thecpuidroute uses its compiled probe), and an aarch64gcc -mcpu=nativename such asneoverse-n1+crc+cryptomatches on the part before the first+.Log redaction reaches back one second before the build began (
redact_sinceinmain.zig). File times have one-second resolution, andtest_secrets_refuse_hostile_input_fileswrites its logs just before it starts the build; on the aarch64 runner a second boundary between the two left a log unredacted.End-to-end evidence (Zen 5 host, EESSI 2026.06, QEMU 11.1.2, job directories on the root filesystem)
--cpu-target x86_64/intel/icelake --mask kvm bzip2-1.0.8-GCCcore-15.2.0.eb --rebuild: 53 s. The guest presentsvendor=GenuineIntel archdetect=x86_64/intel/icelake archspec=icelake gcc=icelake-server; the build installs underx86_64/intel/icelake; the audit passes (no instruction beyond x86_64/intel/icelake, 69722 instructions);eb-local-build-mode.jsonhas"route": "kvm"and"isa_audit": "pass".--cpu-target aarch64/neoverse_n1 --mask tcg zlib-2.3.2-GCCcore-15.2.0.eb --rebuild, first without the option: status 126 in 16 s,vm-run: refused: archspec reads 'aarch64', aarch64/neoverse_n1 needs 'neoverse_n1', then the eb-local message naming--mask-allow-archspec-mismatch. With--mask-allow-archspec-mismatch: the build ran under qemu-user and finished in 8 min 17 s (EasyBuild reports 7 min 6 s for the install itself); the preflight acceptsarchspec names 'aarch64'by the option and checks the rest; the audit passes againstaarch64/neoverse_n1(20893 instructions); the record has"route": "tcg".cpuidroute with the audit on, same binary: bzip2 for zen3 and zen4 pass; the zen4-built tree fails the audit againstx86_64/amd/zen3with exit 1 (see thefeat/cpu-targetPR).zig build unit: 227 tests pass.zig build -Dtest-ops=true test: the same 43 failure lines asdevelopat aecc5a5 on this host, none new.EB_LOCAL_VM_TESTS=1 python3 -m unittest test_vm_run: 8 tests pass in 45 s. CI at the branch head: zig and shellcheck green (runs 45920555278 and 45920555182).