Skip to content

S06-07 - Slot Admission

Purpose: How wb-hostd admits every macOS VM it starts against the limit of two, and lends the isolated VM’s slot to a maintenance VM.

macOS runs at most two macOS guests per host (NFR05-two-macos-vmsNFR05-two-macos-vms: Platform limitmacOS permits at most two concurrently running macOS guests per host.). wb-hostd admits every macOS VM it starts against that limit.

Guests of other operating systems are limited only by resources (NFR05-two-macos-vmsNFR05-two-macos-vms: Platform limitmacOS permits at most two concurrently running macOS guests per host.). These rules don’t apply to them.

These take a slot:

  • the work VM;
  • the isolated VM;
  • a maintenance VM: one that wb-hostd starts for an image rather than for a session.

The maintenance VMs of wb image build are the build VM, under the wb-launcher entry wb-vmd-install (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”), the Claude Code layer’s VM under wb-vmd-layer, and a recipe’s VM under wb-vmd-recipe (S06-17-named-imagesS06-17-named-images: Named Images and RecipesThe build of a named image from a recipe on a clone of the sealed base.). All three run in the build bundle <data>/images/macos-build.noindex (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.).

S06-03-image-updatesS06-03-image-updates: Image UpdatesHow a VM gets a new image's system disk while its data disk and project users stay, and the guest admin password of each VM. has no boot that checks a new image before it replaces a system disk. Such a boot would be a maintenance VM too.

Once its state is saved and it has stopped, a VM doesn’t hold a slot. Xcode work takes no slot of its own (S06-04-vms-and-placementS06-04-vms-and-placement: VMs and PlacementThe work VM and the isolated VM, Xcode in them, and which VM a project's sessions run in., “Xcode in the session’s VM”).

wb-hostd never saves or stops the work VM to make room. A maintenance VM never starts while, by wb-hostd’s count, it would take the slot the work VM needs. That holds even when the work VM isn’t running.

So a maintenance VM runs only in the isolated VM’s slot, and at most one runs at a time.

A maintenance VM may start in two cases:

A debug shell (wb shell) counts as a session here, as for idle suspend. So one open in the isolated VM blocks a lend.

In the second case, wb-hostd first saves the isolated VM’s state and stops it, as at the end of its idle period (S06-06-devices-and-warm-startS06-06-devices-and-warm-start: Devices, Warm Start and TimeA VM's devices and resources, saving and restoring its state, and how the guest clock follows the host., “Warm start”).

A save isn’t always allowed: when the host is locked, a kill is pending, or there is a result of processes left (S06-10-leftover-processesS06-10-leftover-processes: Leftover ProcessesThe results of the kill of a project user, how wb-hostd accepts them, and what it does when processes are left.). wb-hostd then stops the isolated VM cold instead. Those rules allow that without a session.

An open wb vm admin connection blocks a lend as a session does, and a VM whose system disk the admin path marked is stopped cold, never saved (S15-05-admin-pathS15-05-admin-path: The Admin PathHow the person at the host's terminal gets a root shell in their own guest, on a path that no agent, session, or guest process can start or reach., “Marked”).

When the maintenance VM stops:

wb-hostd logs each lend and return with the rule that allowed it.

The lend starts when wb-hostd decides it, before it saves or stops the isolated VM. When it ends depends on the case:

While the lend lasts, wb-hostd refuses every other start or restore of the isolated VM:

  • for a session;
  • for a debug shell;
  • for the recovery of a lost session;
  • for wb vm start.

The return restore is the one start the lend allows. So a refusal names the build, never a VM outside Wraith Box (“Other software” below).

A maintenance VM gets nothing of a session VM

Section titled “A maintenance VM gets nothing of a session VM”

A maintenance VM never gets these of the work VM or the isolated VM:

  • the system disk, data disk, saved state or auxiliary storage;
  • the machine identifier or MAC address.

It doesn’t get a network grant or credential binding of a project (SEC08-proj-isolationSEC08-proj-isolation: Per-project isolationEach project has its own guest user, state and history, and one project cannot persist into another.). The build makes a new VM with its own network (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”).

Its wb-vmd is confined to the build bundle. So it can’t open the work VM’s or the isolated VM’s bundle either (S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves.).

Lending moves a slot, never a VM’s disks or identity. The isolated VM’s wb-vmd (wb-vmd-isolated) never runs the build VM.

Each refusal names the rule, what holds the slots, and how to free one (NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.). wb-hostd refuses:

wb-hostd can’t count macOS VMs that other programs run, such as UTM, Tart, or spike code on a development Mac (I50I50 (closed): Test infrastructure for work that needs a running macOS guestMost v1 work needs a running macOS guest to test: spikes X02-warm-start to X08-data-disk and X17-image-build to X20-shared-homebrew, the conformance suite, and the benchmarks (S11-verification-and-spikes).). It learns of them only when starting or restoring one of its own VMs fails on the Virtualization framework’s limit of running VMs (VZErrorVirtualMachineLimitExceeded in VZError.h).

wb-hostd then refuses the start with vm-limit-other-software. It matches the limit on the framework error’s code, which wb-vmd passes on. wb then:

  • says that a macOS VM outside Wraith Box holds a slot;
  • lists the VMs Wraith Box runs;
  • says to quit the other one.

wb-hostd doesn’t retry, and doesn’t stop one of its own VMs to make room.

The work VM keeps its slot, a maintenance VM borrows the isolated one

Section titled “The work VM keeps its slot, a maintenance VM borrows the isolated one”

Status: Draft