Skip to content

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 ​

StepCommand
Check the filevz validate
Start every nodevz up
Start some nodesvz up r1 r2
Every lab on this Mac, with its nodesvz ls (only running: vz ls --running)
Nodes, NICs and addressesvz node ls
Stop the labvz down
Start a node over from its base imagevz node reset <node> --yes
Delete all statevz destroy --yes
Stop every lab on this Macvz shutdown
See or free vz's disk spacevz clean, then vz clean --cache --state

Check ​

bash
vz validate

validate 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 ​

bash
vz up

up 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 ​

bash
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 ​

CommandWhat 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> / upUnplug or plug both ends of a cable
vz port down <node>/<nic> / upUnplug or plug one NIC
vz media eject <node>/<index> / insertEject or insert a USB disk
vz usb attach <node> <vid:pid> / detachPass 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:

bash
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 memory

The 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 ​

bash
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 once

Sending 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:

bash
vz shutdown             # each lab shuts down like vz down
vz shutdown --force     # power everything off

Reset and destroy ​

bash
vz node reset vm1 vm2 --yes
vz destroy --yes

To free space across all labs, vz clean first shows what ~/.vz holds and how much it takes. Then pick what to delete:

bash
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 images

Running 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 resetdestroy
Lab must be stoppedyes (vz down first)no, it powers the lab off first
Deletesthe 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
Keepsconsole logs; on generic, the machine identifiernothing in the state directory
Afterwardsthe next up boots the clean base and runs cloud-init again; an apple node installs macOS againlike 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 ​

yaml
nestedVirtualization: true

Gives 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 ​

yaml
secureBoot: true

UEFI 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:

bash
vz down && vz node reset secure --yes

USB passthrough ​

yaml
usb:
  - { vendorId: 0x0403, productId: 0x6001 }
bash
vz usb attach vm1 0403:6001
vz usb detach vm1 0403:6001

IDs 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 name gives its default state directory, ~/.vz/state/<name>. Two lab files with the same name share state, so the second up says the lab is already running. Rename one, or give it its own state:.
  • Subnets: switch subnets must not overlap across running labs.
  • Ports: two running labs must not forward the same Mac port.
  • Memory: the memory of 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.

See also ​