Managing labs
This page follows a lab through its life: check it, start it, look at it, change it while it runs, stop it, and clean up. It also covers the node features that depend on your Mac: the memory balloon, nested virtualization, Secure Boot and USB passthrough.
Every command reads lab.yaml in the current folder. Use -f <file> for another lab file, from anywhere.
The lifecycle
| Step | Command |
|---|---|
| Check the file | vz validate |
| Start every node | vz up |
| Start some nodes | vz up r1 r2 |
| Every lab on this Mac, with its nodes | vz ls (only running: vz ls --running) |
| Nodes, NICs and addresses | vz node ls |
| Stop the lab | vz down |
| Start a node over from its base image | vz node reset <node> --yes |
| Delete all state | vz destroy --yes |
| Stop every lab on this Mac | vz shutdown |
| See or free vz's disk space | vz clean, then vz clean --cache --state |
Check
vz validatevalidate reads the file, checks it against the schema and then against vz's own rules (names, references, link ends, subnets, reservations, port forwards, image names). It reports every problem at once, each with its place in the file, for example lab.yaml: nodes[2].interfaces[1].attach: unknown switch 'lan2'. Errors exit with status 1; warnings do not. vz up runs the same checks first. See Validation rules.
Start
vz upup validates the lab, starts a background lab process, and waits until every node is running (up to 180 seconds). Then it returns and prints the nodes and what to do next. The VMs keep running after the terminal closes.
If the lab process exits, a node stops during startup, or the 180 seconds run out, up fails and prints the last 40 lines of <state>/lab.log. Read the whole log there.
vz up r1 r2 starts only those nodes. A link to a node that is not started has nobody at the other end. To add nodes later, run vz down and vz up again.
NOTE
up returns when the VMs run, not when the guests are ready. cloud-init may still be installing packages. See cloud-init.
Look
vz ls # every lab, running or stopped, with its nodes
vz node ls # every node: state, CPUs, memory, NICs, MACs, addresses
vz node ls vm1 # one node (alias: vz node status vm1)
vz topology # switches, links and ports, from the file
vz node console vm1 # serial console in a new window
vz node display vm1 # graphics window
vz node logs vm1 # saved console log (consoleLog: true)Node states are running, paused, stopped, error, and the transitions starting, pausing, resuming, stopping. See Consoles and displays and Networking.
Change a running lab
| Command | What it does |
|---|---|
vz node stop <nodes> | ACPI shutdown, the rest of the lab keeps running. --force powers off; --timeout <s> (default 60) then powers off. |
vz node restart <nodes> | Shut down and start again |
vz node pause <nodes> | Freeze in memory (SSH hangs, routing protocols notice) |
vz node resume <nodes> | Continue a paused node |
vz node memory <node> <size> | Set the memory balloon target |
vz link down <link> / up | Unplug or plug both ends of a cable |
vz port down <node>/<nic> / up | Unplug or plug one NIC |
vz media eject <node>/<index> / insert | Eject or insert a USB disk |
vz usb attach <node> <vid:pid> / detach | Pass a host USB device through |
There is no node start: use node restart to boot a node you stopped.
WARNING
When every node has stopped, the lab process exits, just as with vz down. Stopping the last running node ends the lab.
pause is a cheap way to fail a node: the load balancer and k3s examples use it to watch health checks react.
Memory balloon
Every node has a memory balloon. Lower the guest's memory without a restart:
vz node memory vm1 512MiB
ssh lab@10.101.0.11 free -m
vz node memory vm1 1GiB # back up, at most the node's memoryThe target is a multiple of 1MiB, between Virtualization.framework's minimum and the node's memory. The guest needs a virtio balloon driver; Linux has one.
Stop
vz down # ACPI shutdown of every node, wait up to 60 s, then power off
vz down --timeout 120 # wait longer for slow guests
vz down --force # power off at onceSending SIGINT or SIGTERM to the lab process does the same as vz down; a second signal powers off.
To stop every running lab on this Mac at once, from any folder:
vz shutdown # each lab shuts down like vz down
vz shutdown --force # power everything offReset and destroy
vz node reset vm1 vm2 --yes
vz destroy --yesTo free space across all labs, vz clean first shows what ~/.vz holds and how much it takes. Then pick what to delete:
vz clean # show only, deletes nothing
vz clean --cache # download cache: always safe
vz clean --state # state of every lab that is not running
vz clean --all --yes # cache, stopped labs' state and pulled imagesRunning labs are never touched, and --images is refused while any lab runs. A lab with a state: folder outside ~/.vz keeps it: run vz destroy in that lab's folder.
node reset | destroy | |
|---|---|---|
| Lab must be stopped | yes (vz down first) | no, it powers the lab off first |
| Deletes | the node's overlays, cache layers and cloud-init seed, plus its platform's files: UEFI variables (generic), or the Mac files and install marker (apple) | the whole state directory |
| Keeps | console logs; on generic, the machine identifier | nothing in the state directory |
| Afterwards | the next up boots the clean base and runs cloud-init again; an apple node installs macOS again | like a lab that never ran |
Neither touches disk files at a path in the lab file, such as pulled images or disks vz created next to the lab file. Both ask for confirmation; in scripts or without a terminal, pass --yes.
Host-dependent node features
These keys depend on your Mac. The node feature tour has each one ready to switch on.
Nested virtualization
nestedVirtualization: trueGives the guest /dev/kvm, so it can run its own VMs. It needs an M3 or newer chip. vz validate warns on older Macs, and vz up fails there.
Secure Boot
secureBoot: trueUEFI Secure Boot: only signed boot loaders and kernels boot. The first time the node starts, vz enrolls the default signatures (Microsoft's keys) into the node's UEFI variables. Setting secureBoot: false later does not turn it off, because the variables keep it. Reset the node to clear them:
vz down && vz node reset secure --yesUSB passthrough
usb:
- { vendorId: 0x0403, productId: 0x6001 }vz usb attach vm1 0403:6001
vz usb detach vm1 0403:6001IDs are hexadecimal. In the lab file they can be YAML integers (0x0403) or strings ("0x0403").
IMPORTANT
USB passthrough uses Accessory Access (macOS 27). It needs a vz binary signed with a Developer ID and the com.apple.developer.accessory-access.usb entitlement. The ad-hoc signed builds from make build and the release tarball cannot claim USB devices, so vz up fails for a node with usb devices. Isochronous devices such as webcams and USB audio are not expected to work.
A device listed under usb must be plugged in when the lab starts. vz usb attach needs a node that has a USB controller, which it gets from a usb device or a USB disk in the lab file.
Several labs at once
Labs run side by side, each with its own lab process. For that to work:
- Names: each lab's
namegives its default state directory,~/.vz/state/<name>. Two lab files with the same name share state, so the secondupsays the lab is already running. Rename one, or give it its ownstate:. - Subnets: switch subnets must not overlap across running labs.
- Ports: two running labs must not forward the same Mac port.
- Memory: the
memoryof every running node adds up on the Mac.
All the examples use distinct subnets, MACs and ports, so any of them can run together, memory permitting.