eb-local.vm¶
- module eb-local.vm src/vm.zig[source][autodoc]¶
eb-local __vm-run: run a command under a virtual CPU that presents an EESSI CPU target. An internal helper, absent from--help.--mode kvmboots the host kernel under QEMU with KVM, a named CPU model per target andenforce; the guest’s root is the host’s, read-only over virtiofs, with /cvmfs and the build directories shared.--mode tcgruns the command in qemu user mode withQEMU_CPUset, for a target of another architecture. Before the command starts, the guest checks that EESSI archdetect, archspec,gcc -march=native(or-mcpu=native), the CPU vendor and /dev/fd all name the target, and the helper refuses when one does not.
Types¶
- pub const Mode = enum[source][autodoc]¶
The kind of virtual CPU: KVM for the host’s architecture, qemu user mode for the other.
- pub const Target = struct[source][autodoc]¶
An EESSI CPU target, what each detector must call it, and the QEMU CPU that presents it.
- pub const Plan = union(enum)[source][autodoc]¶
What a mode does for a target on a host: the QEMU CPU, or the reason it cannot.
One virtiofs share: a daemon serving
host, a device taggedtag.Where the guest mounts it; empty for the root and the job directory, which the kernel and the init mount.
Functions¶
- pub fn find(name: []const u8) ?*const Target[source][autodoc]¶
The target named
name, an EESSI software subdirectory.
- pub fn plan(a: Allocator, t: *const Target, mode: Mode, host: Arch) Allocator.Error!Plan[source][autodoc]¶
What
modedoes for targetton ahost: the QEMU CPU, or why it cannot.
- pub fn parseArgs(a: Allocator, args: []const []const u8) Allocator.Error!Parsed[source][autodoc]¶
Parse
--mode kvm|tcg --cpu-target TARGET [--memory MiB] [--cpus N] [--share DIR] [--share-ro DIR] [--allow-archspec-mismatch] -- COMMAND....
- pub fn socketPath(a: Allocator, rundir: []const u8, tag: []const u8) Allocator.Error![]u8[source][autodoc]¶
The vhost-user socket of share
tagin the job directory.
- pub fn kernelCmdline(a: Allocator, rundir: []const u8) Allocator.Error![]u8[source][autodoc]¶
The kernel command line: the host root over virtiofs, read-only, and the init in the job directory.
- pub fn qemuArgv(a: Allocator, cfg: KvmConfig) Allocator.Error![]const []const u8[source][autodoc]¶
The QEMU command line. The CPU is the named model with
enforce; no argument names the host CPU.
- pub fn virtiofsdArgv(a: Allocator, virtiofsd: []const u8, rundir: []const u8, s: Share) Allocator.Error![]const []const u8[source][autodoc]¶
The virtiofsd command line for share
s: no sandbox, read-only when the share is.
- pub fn mountsFile(a: Allocator, shares: []const Share, cvmfs_root: bool) Allocator.Error![]u8[source][autodoc]¶
The guest init’s
mountsfile: one line per mount, parent paths first.
- pub fn dedupePaths(a: Allocator, paths: []const []const u8) Allocator.Error![]const []const u8[source][autodoc]¶
Drop each path that lies inside another one in the list, and repeats; sorted shortest first so that a parent is mounted before its children would be.
- pub fn envForwarded(name: []const u8) bool[source][autodoc]¶
Environment variables the command receives in the guest.
- pub fn shellQuote(a: Allocator, s: []const u8) Allocator.Error![]u8[source][autodoc]¶
sin single quotes for a POSIX shell.
- pub fn jobScript(a: Allocator, j: Job) Allocator.Error![]u8[source][autodoc]¶
The script the guest runs as the caller: the environment, the working directory, the CPU check, then the command.
- pub fn exitStatus(o: Outcome) u8[source][autodoc]¶
The helper’s exit status for what the guest reported. A refusal is 126 whatever else exists; a command’s own status passes through; no report is a VM failure.
Constants¶
- pub const status_refused: u8 = 2[source][autodoc]¶
Refused before anything started: usage, an unknown target, a target this mode cannot present, or a missing tool.
- pub const status_failed: u8 = 125[source][autodoc]¶
The VM or emulator failed, so the command did not report a status.
- pub const status_unverified: u8 = 126[source][autodoc]¶
The guest checked the CPU view and it does not name the target; the command did not run.