Snapshot Resource Kind
Kind: SnapshotapiVersion: pivirt.hu/v1Aliases: snap, snaps
The Snapshot resource declares a point-in-time checkpoint of a virtual machine’s disks and runtime memory state. When applied to a running virtual machine, pivirtd issues guest filesystem freeze (guest-fsfreeze-freeze) via the QEMU Guest Agent and executes QMP savevm to guarantee crash-consistent or application-consistent snapshots.
Accepted Kind Aliases
Section titled “Accepted Kind Aliases”In pivirtctl commands, any of the following aliases are recognized:
Snapshot, snapshot, snapshots, snap, snaps.
Example Manifests
Section titled “Example Manifests”apiVersion: pivirt.hu/v1kind: Snapshotmetadata: name: pre-upgrade-backup labels: scope: maintenancespec: vmName: web-01 description: "Snapshot taken prior to kernel and application upgrade"apiVersion: pivirt.hu/v1kind: Snapshotmetadata: name: clean-state-v1spec: vmName: db-01 description: "Baseline state after initial schema migration"Specification Reference (spec)
Section titled “Specification Reference (spec)”| Field | Type | Required | Default | Description |
|---|---|---|---|---|
vmName |
string |
Yes | Target virtual machine name | |
description |
string |
No | "" |
Human-readable note explaining the snapshot purpose |
Snapshot Lifecycle & Mechanics
Section titled “Snapshot Lifecycle & Mechanics”- Guest Filesystem Quiescing:
- If the guest runs the QEMU Guest Agent,
pivirtdfreezes guest filesystems before committing the snapshot. - If the guest agent is absent or times out, the snapshot proceeds in crash-consistent mode.
- If the guest runs the QEMU Guest Agent,
- QMP Execution:
- For stopped VMs: records disk metadata.
- For running VMs: commits disk copy-on-write delta and captures RAM memory state.
- Owner References:
- Snapshots can specify
ownerReferencespointing to their parentVirtualMachine. WithblockOwnerDeletion: true, the VM cannot be deleted while a critical snapshot exists.
- Snapshots can specify
CLI Management Examples
Section titled “CLI Management Examples”# Apply a snapshot manifest (takes snapshot immediately)pivirtctl apply -f snapshot.yaml
# List all snapshots for the hostpivirtctl get snapshots
# List using short aliaspivirtctl get snaps
# Inspect snapshot metadatapivirtctl describe snapshot pre-upgrade-backup
# Delete a snapshot (safely releases COW delta images)pivirtctl delete snapshot pre-upgrade-backup