In vitro — in glass — is work done outside the living organism, precisely so
the organism is not put at risk. That is what this is for: the machine you ruin
is not the one you work on.
$ vitro run windows # a copy-on-write overlay on a golden image
windows-7f3a2c is up: ssh [email protected] -p 53422
$ vitro exec windows-7f3a2c cargo test
$ echo $? # the guest's exit code, not vitro's
101
$ vitro destroy windows-7f3a2c
Or all of it at once — start a fresh VM, send it this project, run the tests,
and throw the VM away:
$ vitro run --rm --sync . windows -- cargo test
What it is for
Answering "does this actually work on that operating system?" when you do not
have that operating system to hand.
It exists because answering that used to mean buying a second machine, paying
for a hypervisor licence that unlocks its CLI, or asking somebody to click
through an installer. The work that produced vitro had all three of those in
front of it and took none of them.
Three things it has been used for, in earnest:
Settling a question that only Windows can answer. An investigation had
been stuck for weeks because nothing could drive a Windows guest without a
human at its screen.
Doing things to a machine you would not do to yours. Enabling developer
mode, installing several gigabytes of build tools, registering packages,
rewriting ACLs under Program Files. None of it touches the host, and
destroy ends it.
Building software the host cannot build. A Windows ARM64 binary, compiled
and run and looked at, from a Mac.
exec returning the guest's own exit code is what makes the VM a build target
rather than somewhere to poke around by hand: vitro exec win cargo test fails
here exactly when it fails there.
If a Linux guest is all you need, use something else. Docker, Lima and
multipass are faster, lighter and far better worn. vitro earns its place on
Windows and macOS guests, which is where the gap was.
Try it
Two things to install — vitro itself, and QEMU, which brings the guest firmware
with it. With Homebrew, on macOS or Linux, one command does both and adds the
shell completions:
$ brew install lambdalisue/vitro/vitro
With Nix, the flake installs vitro with its shell completions; QEMU comes from
wherever you get it. Main's and every release's builds are kept in the vitro
Cachix cache, which the flake offers on first use — accept it, or run
cachix use vitro once, and this is a download rather than a Rust build:
$ nix profile install github:lambdalisue/vitro # main
$ nix profile install github:lambdalisue/vitro/vX.Y.Z # a release
Or from crates.io, with QEMU installed separately:
vitro completions <shell> prints a completion script for a shell the
packages above did not set up.
Then let vitro do the rest:
$ vitro setup
It makes the SSH key, asks which guest you want first, works out where the
guest firmware is if this host's machine needs one, offers to let scp and
rsync reach VMs by name, and writes a configuration for that host:
key ~/.config/vitro/id_ed25519 (created)
config ~/.config/vitro/config.toml is missing
which guest first? [Windows/linux/macos/skip]
A Windows guest
Answering Windows — the default — gets you the one instruction vitro cannot
carry out for you:
Windows needs an installer ISO, and Microsoft does not allow anyone to
redistribute it — so this is the one part vitro cannot do for you.
1. Open https://www.microsoft.com/software-download/windows11arm64
2. Choose "Windows 11 (multi-edition ISO for Arm-based PCs)", pick a language, and download
3. Save it into ~/.local/share/vitro/media
The filename does not matter: vitro identifies the media by the volume label
inside it. That label also says which architecture the ISO is for, and this
host needs aarch64 — the wrong one does not fail, it stalls at the installer's
first screen, so vitro checks before starting anything.
That page and that edition name are the ones for an Apple Silicon host, which
is what everything below was run on. A guest always matches the host's
architecture, so on x86-64 vitro names Microsoft's ordinary Windows 11
download and the x64 edition instead, and there is no firmware setting to
fill in — that machine boots from QEMU's own BIOS. Nothing else differs.