CLI reference
This page lists every vz command, its arguments and flags, what it prints with --json, and how it exits. Commands that act on the whole lab are top level (vz up). Commands that act on something inside a running lab are noun first (vz node console vm1). The groups below match vz --help.
TIP
Every command has its own help: vz <command> --help, for example vz node logs --help.
Contents
- Global options
- Lab commands:
init,validate,up,down,destroy,ls,topology,shutdown - Runtime commands:
node,link,port,media,usb - Tool commands:
image,clean,schema,completion,version - Human output
- Exit codes
- JSON output
- Environment variables
- Internal commands
Global options
Every lab and runtime command accepts these options. They can go anywhere after the command name.
| Option | Default | Meaning |
|---|---|---|
-f, --file <path> | lab.yaml | The lab file. Relative paths start at the current folder. |
--state <path> | from the lab file | Use this state directory instead of the one set by state: in the lab file (or the default ~/.vz/state/<name>). Relative paths start at the current folder. |
--json | off | Print machine-readable JSON instead of text. See JSON output. |
-v, --verbose | off | Help text: "More logs. Repeat for debug (-vv)." vz up passes it on to the background lab process, but no command prints extra output for it yet. |
--version | Print the version and exit (top level only: vz --version). | |
-h, --help | Show help. |
These commands do not take the global options:
| Command | Its own options |
|---|---|
vz image ls | -o, --output, --json |
vz image pull | -o, --output, --json, --force |
vz shutdown | --force, --timeout, --json |
vz clean | --cache, --state, --images, --all, --yes, --json |
vz schema | none |
vz completion | none |
vz version | none |
NOTE
Most commands need the lab file even when they talk to a running lab, because the lab file says where the state directory (and its control socket) is. Run them from the lab's folder, or pass -f path/to/lab.yaml.
Lab commands
vz init
Create a starter lab.yaml in this folder, or copy a bundled example lab.
vz init # a one-node starter lab.yaml
vz init --example 14 # the whole example folder: lab.yaml, README.md, init/, ...
vz init --example ospf-triangle # the same, by name| Option | Meaning |
|---|---|
--example <name> | Copy a bundled example. <name> is the folder name (14-ospf-triangle), its number (14) or the part after the number (ospf-triangle). |
- The lab file is written to
-f(defaultlab.yaml). With--example, the example'slab.yamlbecomes that file and every other file of the example is copied next to it. initrefuses to overwrite. It fails if the lab file exists, and with--exampleit fails before writing anything if any of the example's files is already there ("Use an empty folder").- The starter lab has one
debian-13node on a NAT switch. Pull its image first:vz image pull disk debian-13.
vz validate
Check the lab file: YAML syntax, the lab file format, and the semantic rules (names, references, subnets, link ends and more). Every problem is collected and shown at once. See Validation rules.
vz validate
vz validate -f other.yaml --jsonExits with 1 if there is at least one error. Warnings are printed but do not fail.
vz up
Create switches, links and disks, then start nodes.
vz up # every node
vz up r1 r2 # only these nodes| Argument | Meaning |
|---|---|
[nodes...] | Nodes to start. Default: all. |
- Validates the lab first and stops on errors.
- Starts a background lab process and returns once every started node is
running(orpaused). The process keeps running after the terminal closes. - On a terminal, shows one live step per node (a spinner, then a check mark with its state, first address and time) and how long it took, from the command to every node running, for example "● running 2 nodes up in 393ms". With
--jsonthe time is thesecondsfield. Running means the VM is powered on; the guest OS keeps booting after that. - Fails if the lab is already running (
try vz down), if a named node does not exist, if the lab process exits, or if a node stops during startup. The last 20 lines of the lab log are shown. - Gives up after 180 seconds. The log is at
<state>/lab.log. - Links between a started node and a node that was not started stay unplugged at the far end.
vz down
Shut down every node (ACPI) and end the lab process.
| Option | Default | Meaning |
|---|---|---|
--force | off | Power off without waiting for the guests. |
--timeout <seconds> | 60 | Seconds to wait for a graceful shutdown. Nodes still running after that are powered off. |
Shows a spinner while the guests shut down, then how long it took, until the lab process has exited, for example "✓ two-vms stopped 803ms". With --json the time is the seconds field. vz node stop prints its time the same way. A guest that is still booting ignores the ACPI shutdown request, so stopping right after up can take the whole timeout.
vz destroy
Stop the lab and delete its state directory: overlays, UEFI variables, machine identifiers, cloud-init seeds, console logs and the lab log.
| Option | Meaning |
|---|---|
--yes | Do not ask for confirmation. Required when stdin is not a terminal. |
If the lab is running, destroy powers it off first (20 second timeout, then SIGKILL after 30 seconds). Files outside the state directory, such as base images and disks created next to the lab file, are not touched.
CAUTION
destroy cannot be undone. Everything written inside overlay disks is lost.
vz ls
List every lab on this Mac, running or stopped, with its nodes. It does not need a lab file.
lab2 running pid 32842 ~/Projects/learning/linux/lab2/lab.yaml
server1 running 10.40.0.11
router1 paused 10.40.0.31
lab-1-dns stopped ~/Projects/learning/kubernetes/lab-1-dns/lab.yaml
vm1
2 labs: 1 running, 1 stopped| Option | Meaning |
|---|---|
--running | Only running labs. |
--json | One object per lab: name, state (running or stopped), pid, file, stateDirectory, nodes (each with name, state and addresses), and note when the nodes could not be listed. |
- Running labs come first. For each, the lab process reports every node's live state (
running,paused,stopped,installing N%) and its addresses. - Stopped labs show the node names from their lab file.
- The list comes from the records in
~/.vz/labs/, one per lab, written byvz upand kept untilvz destroy. Labs with astate:directory elsewhere are listed too. State folders in~/.vz/state/without a record (labs last started by an older vz) are listed with "lab file unknown" until their nextvz up. - A lab counts as running only while its PID is alive, matches
<state>/lab.pid, and belongs to a process namedvz. After a crash, macOS can give the old PID to another program; that program is not mistaken for the lab.
vz topology
Show switches (mode, MTU, IPv4 subnet, IPv6 prefix), links (MTU, ends) and every port with its MAC address. It works from the lab file alone, so the lab does not need to be running. Interfaces without attach are listed as free.
vz shutdown
Stop every running lab on this Mac. Each lab shuts its nodes down (ACPI) and its lab process ends, as with vz down. It does not need a lab file: it finds the labs through the records in ~/.vz/labs/, including labs whose state: directory is elsewhere. vz ls --running shows the same labs.
vz shutdown # graceful
vz shutdown --force # power off| Option | Default | Meaning |
|---|---|---|
--force | off | Power off without waiting for the guests. |
--timeout <seconds> | 60 | Seconds each lab waits for a graceful shutdown. |
--json | off | Print one result per lab. |
It prints one row per lab with the result stopped, or still running (pid N) with the reason and a hint to use --force. It exits with 1 if a lab is still running. With no running labs it prints "No running labs" ([] with --json) and exits with 0.
Runtime commands
These commands talk to the running lab process over its control socket. If the lab is not running they fail with "lab '<name>' is not running. Start it with vz up."
vz node
Inspect, control and open the nodes (VMs) of a lab.
| Command | Arguments and options | What it does |
|---|---|---|
node ls (alias node status) | [nodes...] | State, CPUs, memory, and per NIC: MAC, attach, plug state (up/down) and IP address. Default: all nodes. |
node stop | <nodes...>, --force, --timeout <seconds> (default 60) | Shut down nodes (ACPI); --force powers off. The lab keeps running. |
node restart | <nodes...> | Graceful stop (60 seconds), then start again. |
node pause | <nodes...> | Freeze running nodes in memory. |
node resume | <nodes...> | Resume paused nodes. |
node reset | <nodes...>, --yes | Delete the nodes' overlays, cache layers, cloud-init seed and platform state (UEFI variables on generic; the Mac files and install marker on apple, so macOS installs again). The lab must be stopped. |
node console | <node> | Open the node's serial console in a new Terminal window. |
node display | <node> | Open the node's graphics window. |
node logs | <node>, --boot <n> (default 0), --follow | Print a saved console log. |
node memory | <node> <size> | Set the memory balloon target, for example 512MiB. |
Details:
node lsaddresses. The IP address is found, in order, from the NIC's reservation when macOS's DHCP server holds it (/etc/bootptab), a DHCP lease with the NIC's MAC, the newest lease in the switch subnet with the node's hostname, and finally the reservation in the lab file. A warning is shown when the DHCP server no longer holds the reservation (the fix isvz downandvz up), or when the guest uses a different address than its reservation because its DHCP client id is not its MAC.node restartchecks the reservations a few seconds after the restart and warns when one was dropped. Only switch interfaces get an address.node console. Close the window to detach; the VM keeps running. Every key goes to the VM, there is no escape key. Several windows can attach to the same console. Recent output (up to 64 KiB) is replayed on attach, so the login prompt is visible. Fails early if the node is not running or its platform has no serial console (apple; the error then says what to use instead). SetVZ_TERMINALto use another terminal app.node display. The window is opened by the lab process. Fails if the node hasdisplays: [].node logs. NeedsconsoleLog: trueon the node. A new log file starts each timevz upstarts the node (a reboot inside the guest keeps the same file).--boot 0is the latest file,--boot 1the one before, and so on.--followkeeps printing new output until you press Ctrl+C. It has no short form, because-fis the lab file.node memory. The size usesB,KiB,MiB,GiBorTiB. It must be a multiple of 1MiB, at least the Virtualization framework minimum, and at most the node'smemory. The guest needs a balloon driver (virtio_balloon in Linux).node reset. Asks for confirmation unless--yes. Besides disk layers and the seed, it deletes the files the node's platform names:efi-vars.fdongeneric;mac-hardware-model,mac-machine-id,mac-aux-storageandmacos-installedonapple. On the nextvz upagenericnode starts again from its clean base image with new UEFI variables, so cloud-init runs again, and anapplenode installs macOS again. Ongenericthe machine identifier is kept; console logs are always kept. Disks withoutoverlay: trueare written in place and are not reset.
vz link
Plug or unplug both ends of a cable (a links: entry).
| Command | Argument |
|---|---|
link up <link> | Link name. Plug both ends. |
link down <link> | Link name. Unplug both ends. |
vz port
Plug or unplug one NIC, on a switch or a link.
| Command | Argument |
|---|---|
port up <node>/<interface> | Plug one NIC. |
port down <node>/<interface> | Unplug one NIC. |
The guest sees the NIC lose and regain carrier. The NIC stays in the VM.
vz media
Eject or insert a USB disk (a disk with bus: usb).
| Command | Argument |
|---|---|
media eject <node>/<disk index> | Detach a USB disk. |
media insert <node>/<disk index> | Attach a USB disk again. |
The disk index is the disk's position in the node's disks: list, starting at 0. A USB disk with connected: false starts ejected.
vz usb
Attach or detach a host USB device (passthrough with Accessory Access).
| Command | Arguments |
|---|---|
usb attach <node> <vendorId>:<productId> | Attach a host USB device, for example 0403:6001. |
usb detach <node> <vendorId>:<productId> | Detach it. |
IDs are hexadecimal. The node needs a USB controller, which it gets when it has a usb: device or a USB disk in the lab file.
WARNING
USB passthrough 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 accessories.
Tool commands
vz image
Download OS cloud disks, installer ISOs and macOS restore images for lab files. Names, sources and preparation come from the image makers, one per catalog image. See Images.
vz image ls [disk|iso|ipsw]
List the images vz can pull (cloud disks, ISOs and macOS restore images), and the ones already pulled: name, type, aliases, release, the site that publishes it (for example cloud.debian.org), notes, support level (tested or experimental) and whether it is pulled.
| Option | Meaning |
|---|---|
[disk|iso|ipsw] | Only this type. Default: all. |
-o, --output <dir> | Images directory. Default: ~/.vz/images. |
--json | JSON output. |
vz image pull [disk|iso|ipsw] <name>
Download a cloud disk, an installer ISO or a macOS restore image and verify it.
vz image pull debian-13 # the cloud disk (same as pull disk debian-13)
vz image pull iso debian-13 # the installer ISO
vz image pull ubuntu # an alias
vz image pull ipsw macos # the newest macOS restore image this Mac can run| Argument or option | Meaning |
|---|---|
disk, iso or ipsw | Which kind. Default: disk. |
<name> | Image name or alias, as listed by image ls. Case does not matter. |
-o, --output <dir> | Images directory. Default: ~/.vz/images. |
--force | Pull again even if the image is already there. |
--json | JSON output. |
Files come straight from the publisher, never from a vz server. The pull shows where: the publisher's site in its first line (from cloud.debian.org), then the exact URL of the file as a source step (clickable in terminals that support links). The file is checked against the checksum list the distribution publishes, then unpacked (tar.xz, qcow2 and xz disks become raw disks; ISOs are kept as they are). The verified download stays in ~/.vz/cache, so pulling the same release again does not download it again. The macOS restore image has no checksum list: vz asks Apple (through Virtualization) for the newest macOS this Mac supports, checks the free space, downloads it (about 26 GB) and has Virtualization check the file. After a pull, vz prints the node lines to paste: a disks line, or for an IPSW platform: apple with the .ipsw and a disk to install onto.
IMPORTANT
Replacing a disk with --force makes existing overlays built on the old file invalid. Run vz node reset for the nodes that use it.
vz clean
Show, or delete, what vz keeps in ~/.vz. Without a flag it deletes nothing: it shows each folder, how many items it holds and their size on disk (sparse disks count only what is written).
vz clean # show only
vz clean --cache # delete the download cache
vz clean --state --cache # also the state of labs that are not running
vz clean --all --yes # cache, stopped labs' state and images, no question| Option | Deletes |
|---|---|
--cache | ~/.vz/cache: downloads kept so the next image pull is fast. Always safe. |
--state | Folders in ~/.vz/state of labs that are not running: their overlays, UEFI and Mac state and logs. Those labs start fresh next time. |
--images | ~/.vz/images: pulled base images. Refused while any lab runs, because running nodes read their base images. |
--all | All three. |
--yes | Do not ask for confirmation. Required when stdin is not a terminal. |
--json | JSON output: the report, or the deleted paths. |
- Running labs are never touched: their state is kept and reported as
kept. - A lab whose
state:directory is outside~/.vzkeeps it. Delete that one withvz destroyin its folder. - Before deleting,
cleanlists how many items and how much space it frees, and asks.
CAUTION
Deleting state or images cannot be undone. Overlays of a deleted image no longer work: pull the image again and run vz node reset for its nodes.
vz schema
Print the lab file JSON Schema. Useful for editors and for check-jsonschema:
vz schema > lab.schema.jsonvz completion <shell>
Print the completion script for zsh, bash or fish. The tarball and make install already install the zsh and bash scripts; use this for another prefix or for fish. See Shell completion.
vz completion fish > ~/.config/fish/completions/vz.fishThe script completes commands and flags, and names from the lab file in the current folder (or the one -f names): nodes, links, node/interface ports, catalog images and bundled examples. To get them it runs vz ---completion ..., which reads files only.
vz version
Print the vz version. vz --version does the same. A release prints the version, commit and release run, for example 1.1.0 (commit abc1234, release #12); a binary built from source prints dev.
Human output
Without --json, output is made for reading:
- Symbols.
✓done,✗failed,!warning,›information. Nodes and labs have a dot colored by state: greenrunning, yellowpaused, cyaninstalling, hollowstopped, red on error. - Next steps. Most commands end with a
nextblock that lists the commands worth running after them. Errors end with atryblock when there is a command that fixes them. - Live progress.
up,down,node stop,node restart,shutdownandimage pullredraw their steps in place: a spinner while a step runs, a progress bar with speed and time left for downloads. - Streams. Results go to stdout. Errors, warnings and questions go to stderr.
- Colors and pipes. Colors, live redraws and the blank lines around the output are only used on a terminal. A pipe or a file gets plain text, one line per finished step.
NO_COLORturns colors off,FORCE_COLOR=1turns them on. - Help.
vz,vz --helpand a command group alone (vz node) show a menu of commands;vz <command> --helpshows its arguments and options.
Scripts should use --json: the human output can change between versions.
Exit codes
| Code | Meaning |
|---|---|
0 | Success. |
1 | The command failed: a load or validation error, a refused request, a failed download, an aborted confirmation, or a lab that is not running. With --json, the error is printed as JSON first. |
64 | Bad command line (unknown flag, missing argument). The error shows the command's usage, a close command name when one was mistyped, and the --help to run. |
JSON output
With --json, a command prints one pretty-printed JSON value on stdout with sorted keys. Optional fields are left out when they have no value. Progress lines and prompts go to stderr.
Failures
A failed command prints:
{ "error": "lab 'single-vm' is not running. Start it with vz up.", "ok": false }A lab file that cannot be loaded or has errors prints a validation report instead (see below).
validate and load errors: ValidationReport
{
"file": "lab.yaml",
"lab": "single-vm",
"valid": false,
"issues": [
{ "severity": "error", "path": "nodes[0].interfaces[0].attach", "message": "unknown switch 'lan'" },
{ "severity": "warning", "path": "switches.mgmt", "message": "switch has no interfaces attached" }
]
}lab is missing when the file could not be loaded. path is empty for problems that have no place in the file, such as a YAML syntax error. Commands other than validate print this report only when there are errors.
up, down, node ...: ControlResult
up, down, node stop, node restart, node pause, node resume and node ls print a ControlResult with node reports:
{
"file": "/Users/me/labs/single-vm/lab.yaml",
"name": "single-vm",
"nodeNames": ["vm1"],
"nodes": [
{
"name": "vm1",
"state": "running",
"cpus": 1,
"memory": "1GiB",
"interfaces": [
{
"name": "mgmt",
"mac": "52:54:00:01:01:00",
"attach": "switch/mgmt",
"connected": true,
"reservedIP": "10.101.0.11",
"ip": "10.101.0.11",
"ipSource": "lease"
}
]
}
],
"pid": 41235,
"ready": true,
"stateDirectory": "/Users/me/.vz/state/single-vm"
}| Field | Notes |
|---|---|
pid, ready | Set by up (and by the internal ping). |
nodes[].state | stopped, running, paused, error, starting, pausing, resuming, stopping, saving, restoring or unknown. |
nodes[].memory | The configured size as text, for example 1GiB. |
interfaces[].connected | true when the NIC is plugged in right now. |
interfaces[].reservedIP | The DHCP reservation for this MAC on its switch, if any. |
interfaces[].ip, ipSource | The best known address and where it came from: reservation, lease, hostname or reserved. reservationActive says whether the DHCP server holds the NIC's reservation. |
down for the whole lab may return only { "name": ... }, because the lab process can exit before it replies.
node display, link, port, media, usb and node memory return a short ControlResult whose name says what changed, for example { "name": "r1/eth1" } or { "name": "box/1" }.
topology
{
"switches": [
{
"name": "mgmt",
"mode": "shared",
"ipv4Subnet": "10.112.0.0/24",
"mtu": 1500,
"members": [{ "node": "a", "interface": "mgmt", "mac": "52:54:00:12:01:00" }]
}
],
"links": [
{
"name": "a-b",
"mtu": 1500,
"ends": [
{ "node": "a", "interface": "p2p", "mac": "52:54:00:12:01:01" },
{ "node": "b", "interface": "p2p", "mac": "52:54:00:12:02:01" }
]
}
],
"free": []
}mode is shared (NAT) or host. ipv6Prefix appears when set.
ls (running labs)
[
{ "name": "single-vm", "file": "/Users/me/labs/single-vm/lab.yaml", "state": "/Users/me/.vz/state/single-vm", "pid": 41235 }
]init, node reset, destroy, node logs, node console
// init
{ "ok": true, "file": "/Users/me/lab/lab.yaml" }
// init --example: also the copied files, relative to the folder
{ "ok": true, "file": "/Users/me/lab/lab.yaml", "files": ["README.md", "init/vm1/network-config", "init/vm1/user-data", "lab.yaml"] }
// node reset: absolute paths of the deleted files
{ "ok": true, "removed": ["/Users/me/.vz/state/single-vm/vm1/disk0.overlay.asif", "..."] }
// destroy: the deleted state directory
{ "ok": true, "removed": "/Users/me/.vz/state/single-vm" }
// node logs (without --follow)
{ "file": "/Users/me/.vz/state/single-vm/vm1/console-20261129-101500.log", "boot": 0, "text": "..." }
// node console
{ "ok": true, "node": "vm1", "window": true, "app": "Terminal" }With --follow, node logs prints the raw log even when --json is set.
image ls and image pull
// image ls: one entry per image
[
{
"name": "debian-13",
"kind": "disk",
"title": "Debian 13 trixie cloud",
"notes": "cloud kernel, no displays",
"support": "tested",
"source": "https://cloud.debian.org/images/cloud/trixie/latest/",
"aliases": ["debian"],
"path": "/Users/me/.vz/images/debian-13-genericcloud-arm64.raw"
}
]
// image pull: "pulled" is false when the file was already there
{ "ok": true, "name": "debian-13", "kind": "disk", "path": "/Users/me/.vz/images/debian-13-genericcloud-arm64.raw", "pulled": true }path in image ls is present only when the image has been pulled. support is tested or experimental. source is the folder of the image's checksum list on the publisher's site; it is absent for the macOS restore image, whose URL Apple gives at pull time.
Environment variables
| Variable | Used by | Meaning |
|---|---|---|
VZ_HOME | every command | Where vz keeps state, the running-lab registry, images and the download cache. Default ~/.vz. Must be an absolute path (or start with ~); a relative value is ignored. |
VZ_TERMINAL | node console | The terminal app to open, for example iTerm. Default Terminal. |
NO_COLOR | every command | Any value turns colors off. See Human output. |
FORCE_COLOR | every command | Any value except 0 turns colors on, even in a pipe. |
PATH | image pull | Searched for qemu-img (also /opt/homebrew/bin and /usr/local/bin). |
See Files and environment for the full picture.
Internal commands
Hidden commands that vz runs itself
These are not shown in --help and are not a stable interface.
| Command | Started by | What it does |
|---|---|---|
vz __run-lab -f <file> --state <dir> [-v...] [-- nodes...] | vz up | The background lab process. It owns the VMs, switches, links and display windows, writes lab.pid, registers the lab for vz ls, and serves the control socket until every VM has stopped. SIGINT or SIGTERM shuts the lab down gracefully; a second signal powers off. |
vz __console -f <file> --state <dir> <node> | the window opened by node console | Attaches the terminal, in raw mode, to the node's serial console until the window closes or the lab stops. |
node console writes a small console.command script into <state>/<node>/ and opens it with open -a <terminal>. That needs no Automation permission.
See Control protocol for what these processes say to each other.