S04-10 - Installing macOS in `wb-vmd`
Purpose: The wb-vmd-install entry of an image build: its install
rules, the restore image it reads, the build bundle it installs into,
and its Install call. The other slots are in S04-04-vm-processesS04-04-vm-processes: Per-VM ProcessesOne wb-vmd for each VM, the wb-vmd-layer entry of the Claude Code layer build, the wb-vmd-recipe entry of a named image's recipe, and wb-diskfmt, which formats a VM's new data disk..
Design
Section titled “Design”wb-vmd-install
Section titled “wb-vmd-install”An image build installs macOS through a third fixed entry,
wb-vmd-install. Its compiled-in profile is the wb-vmd profile plus
the three rules an install needs:
- reading the restore image;
- a read extension for it;
- the installation service, which calls Apple (S17-04-restore-and-releaseS17-04-restore-and-release: Restore Image and ReleaseThe steps by which wb-download and wb-hostd fetch and check a macOS restore image and a Claude Code release.).
Only the image build needs those rules. The session VMs’ wb-vmd
instances don’t have them (SEC12-least-privilegeSEC12-least-privilege: Least privilege on the hostNo root or administrator rights at run time and no extra host user accounts.).
The restore image
Section titled “The restore image”The install reads the restore image only at the fixed path
<data>/images/macos-restore.ipsw. wb-download fetches it, and
wb-hostd checks its hash before it starts wb-vmd-install
(S17-03-downloadsS17-03-downloads: DownloadsHow wb-download fetches what an image build needs from the internet.).
Before it confines itself, wb-vmd-install opens the restore image
once, without following a symbolic link, and checks that descriptor.
It refuses to start, logs the rule and exits unless these hold
(vmd-restore-image-mismatch):
- the descriptor is a regular file;
- the file has one link, so a hard link to a file elsewhere is refused;
- the file is owned by the user
wb-vmd-installruns as; - the descriptor path is
images/macos-restore.ipswunder the real path of<data>.
The build bundle
Section titled “The build bundle”The install target is the fixed build bundle
<data>/images/macos-build.noindex. That is the entry’s profile
parameter, never a path from the request. So the install can’t write
into the work VM’s or the isolated VM’s bundle. The request doesn’t
choose the mode, the image, or a path.
The same instance then runs the build VM’s provisioning boot and the rest of the build in that bundle, confined to it (S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Built by Wraith Box”). It exits when the build ends. Its instance cap is one, because one maintenance VM runs at a time (S06-07-slot-admissionS06-07-slot-admission: Slot AdmissionHow wb-hostd admits every macOS VM it starts against the limit of two, and lends the isolated VM's slot to a maintenance VM.).
Only this entry accepts provisioning options. An instance whose slot
isn’t build, layer included, refuses them and logs vmd-provisioning-refused
(S15-04-guest-adminS15-04-guest-admin: The Guest Admin UserHow the host keeps the password of the guest admin user wbadmin, from the image build to each VM's first contact., “Refused outside the path”). The provisioning
check is the first step of a start with provisioning set, so a refused
slot never reads a password or creates a device. A start call with
the Xcode flag in any slot but layer is refused before any device is
created, and logs vmd-xcode-disk-refused (S06-14-xcode-imageS06-14-xcode-image: The Xcode ImageHow an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode's first launch.).
The build password pipe
Section titled “The build password pipe”In the build slot, wb-vmd inherits descriptor 5, the read end of
the build password pipe (S04-11-vmd-startS04-11-vmd-start: Starting `wb-vmd`What wb-vmd inherits from its spawner, the socket it serves gRPC on, its lifeline, and the checks on each connection., “How wb-vmd is
started”). It refuses to start with vmd-descriptor-invalid when
descriptor 5 isn’t a pipe opened for reading only, and wb-hostd
refuses to pass anything but a pipe.
wb-vmd reads the password from it only for a start with
provisioning set, after the provisioning check and the start’s other
checks have passed. The password is read to end of file within a
deadline, and must be 1 to 256 bytes of printable ASCII. Anything else
refuses the start with vmd-provisioning-password-invalid. wb-vmd
reads the pipe once. It closes the pipe when the first start call
returns, also when that call didn’t read it. A later start with provisioning set is refused
with vmd-provisioning-password-invalid.
wb-vmd keeps the password as bytes until the framework call that sets
the provisioning options, and wipes them once the call returns. The
framework takes the password as a string, which can’t be wiped, and
wb-vmd keeps no reference to that copy after the call. The password never reaches a log, an
error, or a file (SEC04-no-guest-secretsSEC04-no-guest-secrets: No secrets in the guestThis includes the model credential.).
The install call
Section titled “The install call”Install installs macOS from the restore image into the build bundle.
Its request holds the CPU count and memory, as a start’s does. It
doesn’t name a path or an image. The call streams the install’s
progress in whole percents, one message per step at most. The last
message says 100 once the install is done. Only
the build slot serves it. Every other slot refuses it before it touches
a file, and logs vmd-install-refused.
In the build slot, the call:
- refuses a call while an install runs or a VM starts or runs
(
vmd-install-refused); - checks the CPU count and memory against the host’s range
(
vm-resources); - refuses a second install in the same instance, and a bundle that
already holds
hw.bin,mid.bin,aux.wbstoreorsys.wbdisk(vmd-install-refused); - reads the restore image at the fixed path, and refuses one this
host can’t run with
vmd-restore-image-unsupported; - creates
hw.binwith the image’s hardware model,mid.binwith a new machine identifier,aux.wbstore, and a sparse 64 GiBsys.wbdisk, each withO_EXCL; - installs with the build slot’s fixed set, which has no network
device.
wb-hostdputstools.imgand an emptydata.wbdiskin the bundle first. With them, the set passes its check (S04-02-vm-providerS04-02-vm-provider: VM Provider and StreamsHow wb-vmd hands guest connections and the NIC endpoint to other processes, the fixed device set of a VM, and where wb-proxyd takes a stream's identity from., “The device set is fixed and checked”).
A framework error ends the stream with a message that holds its
VMError, and the call is refused with vm-install-failed. The
instance then serves boots of the bundle with Start, each a new
generation, as the other slots do. A closed lifeline during an
install ends wb-vmd within its exit deadline, and the install with
it. The build then fails, and wb-hostd deletes the build bundle
(S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “The build bundle”). A caller that abandons the
stream doesn’t stop the install. It runs on until wb-hostd closes
the lifeline, and the build then fails the same way (I655I655 (closed): wb-hostd: the image build: build bundle, wb-vmd-install start, the restore image, taking the sealed image and the image recordsPackage IMG.2 of docs/implementation-plan.md, part 2 of 5 (IMG.2b).).
Decisions
Section titled “Decisions”A separate entry for the install
Section titled “A separate entry for the install”The image build’s install runs as its own entry, wb-vmd-install,
with the install rules that the session VMs’ instances don’t have.
- Decided: I64I64 (closed): X25-vmd-sandbox: Self-sandboxed wb-vmdFound while answering #34 (X23-sandboxed-daemons)., B64-vmd-sandboxB64-vmd-sandbox: Can wb-vmd confine itself and still run a macOS VM?Yes, with conditions..
Status: Draft