Skip to content

pivirtctl Reference & Resource Kinds

Host CLIDeclarative GitOpsUnix Socket gRPCapiVersion: pivirt.hu/v1

pivirtctl is the direct host-level command-line tool for managing the pivirtd hypervisor runtime. It talks directly to pivirtd over a private Unix domain socket (/var/run/pivirt/pivirtd.sock or $PIVIRTD_SOCKET), providing both a declarative Kubernetes-style GitOps engine (apply, get, describe, delete) and imperative operational commands (vm, disk, snapshot, device).


Terminal window
pivirtctl [command] [flags]
Flag Shorthand Description Default
--socket Path to the pivirtd Unix domain socket /var/run/pivirt/pivirtd.sock or $PIVIRTD_SOCKET
--output -o Output format: table, json, yaml, wide table
--help -h Display help for command or subcommand

PiVirt features a declarative resource engine that mirrors Kubernetes YAML workflows for virtualization infrastructure. All resources belong to the apiVersion: pivirt.hu/v1 group.

When multiple resources are processed together, pivirtctl automatically resolves dependencies:

  • Apply Order (Creation): StoragePool → Network / OverlayNetwork → ExternalIP → VirtualDisk → VirtualMachine → Snapshot.
  • Delete Order (Teardown): Reverse dependency order (Snapshot → VirtualMachine → VirtualDisk → ExternalIP → Network → StoragePool), preventing orphaned mounts, lingering firewall rules, or hanging router namespaces.

Applies one or more declarative resource manifests to the host hypervisor. If the resource does not exist, it is created. If it already exists and its specification has changed, it is updated and the host generation is incremented.

Terminal window
pivirtctl apply -f <path> [flags]
Flag Shorthand Description Default
--filename -f Path to a YAML file, directory, or - for stdin Required
--recursive -R Process directories recursively false
--dry-run Run decode, admission, validation, and interlocks without persisting false
Terminal window
# Apply a single VirtualMachine manifest
pivirtctl apply -f vm-web-01.yaml

Output:

virtualmachine/web-01 created

Lists or retrieves declarative resources from the local host store.

Terminal window
pivirtctl get <kind> [name] [flags]
pivirtctl get <kind>/<name> [flags]

pivirtctl accepts singular names, plurals, short names, and multi-word names interchangeably:

Canonical Kind Accepted Aliases & Plurals
VirtualMachine vm, vms, virtualmachine, virtualmachines, virtual-machine, virtual-machines
StoragePool pool, pools, storagepool, storagepools, storage-pool, storage-pools, storage
VirtualDisk disk, disks, virtualdisk, virtualdisks, virtual-disk, virtual-disks
Network net, nets, network, networks, bridge, bridges, hostbridge
NetworkSegment segment, segments, networksegment, networksegments, network-segment
DHCPLease lease, leases, dhcplease, dhcpleases, dhcp-lease
OverlayNetwork overlay, overlays, overlaynetwork, overlaynetworks, overlay-network
ExternalIP ippool, ippools, ip-pool, externalip, externalips, extip, ip, ips
Snapshot snap, snaps, snapshot, snapshots
Flag Shorthand Description Default
--selector -l Label selector query to filter resources
--output -o Output format: table, yaml, json, wide table

The label selector supports full Kubernetes-compatible query syntax:

  • Equality: environment=production, tier=frontend
  • Inequality: environment!=staging
  • Set Membership: tier in (frontend, api)
  • Set Exclusion: environment notin (dev, test)
  • Key Existence: backup-policy
  • Key Non-Existence: !temporary
  • Conjunction (AND): Comma-separated: environment=production,tier=frontend
Terminal window
# List all virtual machines
pivirtctl get vms
# List all storage pools (multi-word alias supported)
pivirtctl get storage pools
# List all networks
pivirtctl get networks

Output:

NAME KIND STATUS AGE
web-01 VirtualMachine Running 2h
db-01 VirtualMachine Stopped 1d

Displays detailed runtime inspection, specification fields, observed generation, metadata, and status for a specific resource.

Terminal window
pivirtctl describe <kind> <name>
pivirtctl describe <kind>/<name>
Terminal window
pivirtctl describe vm web-01

Output:

Name: web-01
Kind: VirtualMachine
API Version: pivirt.hu/v1
Generation: 2
Observed Gen: 2
UID: 8f3a9e21-bc14-41d3-a55b-4395b0c9a128
Labels:
environment: production
tier: frontend
pivirt.hu/owner-org: acme-corp
pivirt.hu/generation: 7
Spec:
CPU: 2 Cores (host-passthrough)
Memory: 4 GiB (4294967296 bytes)
Disks:
- Name: root-disk (size: 20 GiB, format: qcow2, bus: virtio)
Interfaces:
- Name: eth0 (bridge: virbr0, model: virtio)
Status:
Phase: Running
PID: 41209
QMP Socket: /var/lib/pivirt/vms/web-01/run/qmp.sock

Deletes one or more declarative resources from the host. Deletions execute cascading teardowns (removing associated child resources like attached disks or local snapshots) and clean up host-level constructs (bridges, TAP devices, mounts, firewall chains).

Terminal window
pivirtctl delete <kind> <name>...
pivirtctl delete <kind>/<name>
pivirtctl delete -f <filename|directory> [-R]
pivirtctl delete <kind> -l <selector>
pivirtctl delete <kind> --all
Flag Shorthand Description Default
--filename -f File or directory containing resources to delete
--recursive -R Process directory recursively with -f false
--selector -l Selector (label query) to filter resources to delete
--all Delete all resources of the specified kind false
Terminal window
# Delete single resource
pivirtctl delete vm web-01
# Delete multiple resources at once
pivirtctl delete vm web-01 web-02 db-01
# Delete using kind/name syntax
pivirtctl delete vm/web-01

Output:

virtualmachine/web-01 deleted

Every declarative manifest adheres to the Kubernetes-style apiVersion: pivirt.hu/v1 envelope. To keep documentation organized and deep, each Kind has a dedicated reference sub-page with comprehensive field specifications, architectural notes, and copy-pasteable YAML examples:

Kind Accepted Aliases Key Capabilities Specification Guide
VirtualMachine vm, vms, virtualmachine vCPU topology, RAM, disks, NICs, UEFI/TPM, cloud-init VirtualMachine Reference →
StoragePool pool, pools, storagepool Local and networked storage mounts (dir, zfs, lvm, nfs) StoragePool Reference →
VirtualDisk disk, disks, virtualdisk Standalone disks or dynamic VM attachments (qcow2, raw) VirtualDisk Reference →
Network net, nets, bridge Linux bridges, isolated networks, NAT routing, VLAN trunks Network Reference →
NetworkSegment segment, segments Host bridge binding and delegated host DHCP range NetworkSegment Reference →
DHCPLease lease, leases, dhcplease Active host DHCP leases and declarative static IP reservations DHCPLease Reference →
OverlayNetwork overlay, overlays Multi-host tunnel meshes using OVS VXLAN or Geneve OverlayNetwork Reference →
ExternalIP ippool, ippools, extip Public IP bindings, 1:1 NAT, and port forwarding ExternalIP Reference →
IPAllocation ipam, allocation Cluster IPAM pool management and port bindings IPAllocation Reference →
Snapshot snap, snaps, snapshot Point-in-time VM disk and memory state checkpoints Snapshot Reference →

In addition to declarative YAML manifests, pivirtctl provides imperative commands for day-to-day diagnostics and power operations.

Manages virtual machine power states, live consoles, and logs.

Terminal window
# Start a virtual machine
pivirtctl vm start web-01
# Graceful shutdown (ACPI)
pivirtctl vm stop web-01
# Forceful power off
pivirtctl vm stop web-01 --force
# Reboot a virtual machine
pivirtctl vm restart web-01
# Pause and resume guest execution
pivirtctl vm pause web-01
pivirtctl vm resume web-01
# View QEMU console logs
pivirtctl vm logs web-01 --tail 50
Terminal window
pivirtctl vm create web-01 \
--vcpus 4 \
--memory 8192 \
--disk size=40GB,format=qcow2 \
--net type=bridge,br=virbr0

Performs live disk operations on running or stopped virtual machines.

Terminal window
# List all disks attached to a VM
pivirtctl disk list web-01
# Live disk expansion (via QMP block_resize without restarting VM)
pivirtctl disk resize web-01 root-disk 50GB
# Inspect virtual disk image properties
pivirtctl disk info /var/lib/pivirt/vms/web-01/disks/disk0.qcow2

Manages live snapshot trees and rollbacks.

Terminal window
# List snapshots for a VM
pivirtctl snapshot list web-01
# Create a snapshot with description
pivirtctl snapshot create web-01 snap-1 --description "Clean install"
# Revert VM to a previous snapshot
pivirtctl snapshot revert web-01 snap-1
# Delete a snapshot
pivirtctl snapshot delete web-01 snap-1

Streams live hardware metrics and resource consumption directly from hypervisor cgroups and QMP.

Terminal window
# Stream live hypervisor CPU, memory, and disk I/O metrics
pivirtctl top
# Stream detailed stats for a single VM
pivirtctl monitor web-01

System Architecture

Learn how pivirtd decouples from the agent and director in the System Architecture.

pvcli Reference

Explore the multi-node, cluster-wide operator CLI in the pvcli Guide.

YAML Schema Guide

Inspect daemon configuration schemas in the YAML Reference.