API Reference
VM Service ConnectRPC and gRPC definitions.
View API Reference
pivirtd is the core hypervisor daemon that directly manages QEMU/KVM virtual machines. It exposes a gRPC API for VM lifecycle operations and runs as a systemd service on each hypervisor node.
| Property | Value |
|---|---|
| Language | Go 1.22+ |
| Protocol | gRPC (internal), ConnectRPC (via agent) |
| Runtime | systemd service, runs as root |
| Dependencies | QEMU/KVM, Cloud Hypervisor (optional) |
| Config | /etc/pivirtd/config.yaml |
| Log | journald / /var/log/pivirtd/ |
flowchart TB
subgraph Pivirtd["pivirtd Architecture"]
subgraph Top["Management Layer"]
API["gRPC API<br/>(Port 9001)"]
VMM["VM Manager"]
RES["Resource Tracker<br/>(CPU, Mem, Disk)"]
end
subgraph HAL["Hypervisor Abstraction Layer"]
QEMU["QEMU/KVM<br/>(go-qemu / QMP)"]
CH["Cloud Hypervisor<br/>(VMM)"]
FUT[(Future)]
end
API --> HAL
VMM --> HAL
RES --> HAL
end
block_resizeCreateSnapshot freezes the guest filesystem (fsfreeze) before capture, with a crash-consistent fallback if the agent is unreachablepivirtd manages both local and clustered storage through dedicated storage pools.
The file tree below illustrates how pivirtd structures runtime files, base images, guest disks, and control sockets on the host filesystem:
| Backend | Type | Use Case | Performance |
|---|---|---|---|
| dir | File | Development, single-node | ★★☆☆☆ |
| lvm | Block | Production, thin provisioning | ★★★★☆ |
| iscsi | Block | Clustered, shared storage | ★★★★★ |
| nfs | File | Shared, backup targets | ★★★☆☆ |
| rbd | Block | Ceph clusters | ★★★★★ |
/etc/pivirtd/config.yaml)# pivirtd configurationserver: grpc_addr: "0.0.0.0:9001" http_addr: "0.0.0.0:9002" # Metrics, health tls: cert_file: "/etc/pivirtd/tls/server.crt" key_file: "/etc/pivirtd/tls/server.key" ca_file: "/etc/pivirtd/tls/ca.crt"
hypervisor: type: "qemu" # qemu | cloud-hypervisor default_machine_type: "pc-q35-8.0" cpu_model: "host-passthrough"
listen_tcp: "0.0.0.0:8443"tls_cert_file: "/etc/pivirtd/tls/server.crt"tls_key_file: "/etc/pivirtd/tls/server.key"
storage: default_pool: "default" pools: - name: "default" type: "dir" path: "/var/lib/pivirt/images" - name: "iscsi-pool" type: "iscsi" target_iqn: "iqn.2024-01.hu.pilab:pivirtd" portal: "10.0.1.10:3260"
network: default_bridge: "virbr0" bridges: - name: "virbr0" type: "bridge" interface: "eth0" - name: "vxlan0" type: "vxlan" vni: 1000 remote: "10.0.1.20"
logging: level: "info" format: "json" output: "journald"
metrics: enabled: true path: "/metrics"proto/pivirt/vm/v1/vm.proto)service VMService { rpc CreateVM(CreateVMRequest) returns (VM); rpc GetVM(GetVMRequest) returns (VM); rpc ListVMs(ListVMsRequest) returns (stream VM); rpc UpdateVM(UpdateVMRequest) returns (VM); rpc DeleteVM(DeleteVMRequest) returns (Empty);
rpc StartVM(StartVMRequest) returns (Empty); rpc StopVM(StopVMRequest) returns (Empty); rpc RebootVM(RebootVMRequest) returns (Empty); rpc ShutdownVM(ShutdownVMRequest) returns (Empty);
rpc CreateSnapshot(CreateSnapshotRequest) returns (Snapshot); rpc ListSnapshots(ListSnapshotsRequest) returns (stream Snapshot); rpc RestoreSnapshot(RestoreSnapshotRequest) returns (Empty); rpc DeleteSnapshot(DeleteSnapshotRequest) returns (Empty);
rpc GetConsole(GetConsoleRequest) returns (stream ConsoleOutput); rpc GetVNC(GetVNCRequest) returns (VNCInfo); rpc MigrateVM(MigrateVMRequest) returns (MigrationStatus);}# Using grpcurlgrpcurl -plaintext -d '{ "spec": { "name": "web-01", "cpu": { "cores": 2, "model": "host-passthrough" }, "memory": { "size_mib": 4096 }, "disks": [{ "size_gib": 20, "pool": "default", "bus": "virtio" }], "nics": [{ "bridge": "virbr0", "model": "virtio" }], "os": { "type": "linux", "boot_order": ["disk", "network"] } }}' localhost:9001 pivirt.vm.v1.VMService/CreateVMnics: - bridge: virbr0 model: virtio vlan: 100 # Optional VLAN tagnics: - network: vxlan0 model: virtionics: - pf: eth2 vf: 0 model: vfio-pcipivirtd is continuously built with GoReleaser and published as native .deb and .rpm packages to the official PiLab Package Repository at https://dl.pilab.hu. The package bundles:
pivirtd: The core hypervisor daemon (/usr/bin/pivirtd)pivirtctl: The local host management CLI (/usr/bin/pivirtctl)/usr/share/pivirtd/assets/OVMF_VARS.fd)/lib/systemd/system/pivirtd.service)# 1. Add PiLab GPG signing keysudo mkdir -p /etc/apt/keyringscurl -fsSL https://dl.pilab.hu/pivirt.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/pilab.gpg
# 2. Add PiLab APT repositoryecho "deb [signed-by=/etc/apt/keyrings/pilab.gpg] https://dl.pilab.hu/deb stable main" | sudo tee /etc/apt/sources.list.d/pilab.list
# 3. Update & Install pivirtdsudo apt-get updatesudo apt-get install -y pivirtd# 1. Add PiLab YUM/DNF repositorysudo tee /etc/yum.repos.d/pilab.repo <<EOF[pilab]name=PiLab Packagesbaseurl=https://dl.pilab.hu/rpmenabled=1gpgcheck=1gpgkey=https://dl.pilab.hu/pivirt.gpgEOF
# 2. Install pivirtdsudo dnf install -y pivirtdpivirtd is managed via systemd:
# Start the daemonsudo systemctl start pivirtd
# Stop the daemonsudo systemctl stop pivirtd
# Restart the daemonsudo systemctl restart pivirtd
# Check statussudo systemctl status pivirtd
# Enable on bootsudo systemctl enable pivirtd
# View logssudo journalctl -u pivirtd -f# gRPC Health Checkgrpcurl -plaintext localhost:9001 grpc.health.v1.Health/Check
# HTTP Health Checkcurl http://localhost:9002/healthcurl http://localhost:9002/readycurl http://localhost:9002/live
# Prometheus Metricscurl http://localhost:9002/metricsAPI Reference
VM Service ConnectRPC and gRPC definitions.
View API Reference
CLI Reference
Daemon commands, options, and operational flags.
View CLI Reference
Storage Guide
Detailed configuration of directory, LVM, and iSCSI pools.
View Storage Guide
Live Migration
Shared-storage and shared-nothing live migration protocols.
View Migration Guide