Libvirt / KVM Provider¶
The libvirt provider manages VMs on KVM/QEMU hosts. It runs virsh and a few host tools (qemu-img, genisoimage, isoinfo) on the libvirt host over SSH. It is the provider that gained the most in v0.4.0: private cloud-init seeds, VM ownership stamps, snapshot revert, clone identity, honest reconfigure results, and an experimental clustered topology. v0.4.1 makes secure boot, UEFI, VT-d, nested virtualization and multi-NIC VMs work, and closes the snapshot problems v0.4.0 listed as known limitations.
This page is aligned to VirtRigaud v0.4.2. Capability claims trace back to GetCapabilities and clusteredCapabilities in internal/providers/libvirt/server.go.
How the provider drives libvirt (v0.4.2)
Every operation that changes state, and every read the manager acts on, still goes through virsh run on the hypervisor host. The provider reaches the host with an in-process SSH client (internal/providers/libvirt/sshclient.go), one persistent connection per host, so the provider image carries no ssh/sshpass binary and no key is written to disk. There is no cgo and no libvirt-dev in the image.
A pure-Go go-libvirt client exists in the provider (ADR-0008) but is dormant by default. It can be switched on only as an opt-in shadow read: VIRTRIGAUD_LIBVIRT_NATIVE=shadow:describe,shadow:list makes the provider run Describe and ListVMs through both paths, return the virsh answer, and count any divergence in a metric. A native: mode is accepted but is downgraded to shadow at v0.4.0: no read is served from go-libvirt. See Libvirt shadow-compare reads.
Topologies: single host or cluster¶
A libvirt Provider is bound to one host by default (spec.topology: single, the default). Since v0.4.0 it can instead front a pool of bare hosts:
| Single host (default) | Cluster (spec.topology: cluster) | |
|---|---|---|
| What the Provider fronts | One libvirt host, named by spec.endpoint | Every Host custom resource that references the Provider (grouped by a HostPool) |
| Placement | None: the VM lands on the one host | The manager's scheduler picks a host (filters on host health, schedulability, required net.virtrigaud.io/<network> labels, free capacity and an optional VMPlacementPolicy, then scores with the pool's Spread or BinPack strategy) |
| Per-VM calls | Addressed by domain name | Routed to the VM's bound host (status.placement) and owner-checked there |
| Maturity | Supported | Experimental. Opt-in, may still change. Host-to-host migration is not implemented. |
spec.topology is immutable once set, and the validating webhook accepts cluster only on type: libvirt. A clustered Provider's runtime always runs as one replica with the Recreate strategy, whatever spec.runtime.replicas says, so it is briefly unavailable during a rollout.
apiVersion: infra.virtrigaud.io/v1beta1
kind: Provider
metadata:
name: libvirt-cluster
namespace: virtrigaud-system
spec:
type: libvirt
topology: cluster
endpoint: qemu+ssh://virtrigaud@libvirt-host.example.com/system
credentialSecretRef:
name: libvirt-cluster-creds
runtime:
mode: Remote
image: "ghcr.io/projectbeskar/virtrigaud/provider-libvirt:v0.4.2"
service:
port: 9443
tls:
enabled: true
secretRef:
name: libvirt-cluster-tls
---
apiVersion: infra.virtrigaud.io/v1beta1
kind: HostPool
metadata:
name: pool-a
namespace: virtrigaud-system
spec:
providerRef:
name: libvirt-cluster
strategy: Spread
---
apiVersion: infra.virtrigaud.io/v1beta1
kind: Host
metadata:
name: host-a
namespace: virtrigaud-system
spec:
providerRef:
name: libvirt-cluster
poolRef:
name: pool-a
endpoint: qemu+ssh://virtrigaud@host-a.example.com/system
labels:
net.virtrigaud.io/default: "true"
Placement, the Host and HostPool fields, restore guards, the re-attach runbook and migration into a clustered Provider are covered in the Clustered libvirt guide and its pages on placement, operations and backup and restore; migrating a VM into one is in Migrating into a clustered Provider. A clustered Provider serves a subset of the single-host features; the differences are marked in the tables below.
Capabilities at a glance¶
The provider advertises the following via GetCapabilities (internal/providers/libvirt/server.go). A clustered Provider reports only what is routed to a host (clusteredCapabilities).
| Capability flag | Single host | Clustered | What it means |
|---|---|---|---|
SupportsReconfigureOnline | true | true | Online CPU/memory changes via virsh setvcpus/setmem --live for VMs created with hot-add headroom (see Reconfigure). Other changes are applied to the definition and take effect at the next power cycle. |
SupportsHonestReconfigure | true | true | Reconfigure reports applied, restart required or failed and never claims a change it did not make. |
SupportsDiskExpansionOnline | true | true | Live disk grow via virsh blockresize plus a best-effort in-guest filesystem grow; grow-only. |
SupportsSnapshots | true | true | virsh snapshot-create-as. |
SupportsMemorySnapshots | true | true | RAM-inclusive snapshots of a running VM. |
SupportsLinkedClones | false | false | Linked clones are disabled in v0.4.2 (see Cloning). Full clones work. |
SupportsImageImport | true | not reported | ImagePrepare for source.libvirt.url. A clustered Provider does not prepare images. |
SupportsImageArtifactIdentity | true | not reported | Prepared images are named, stamped and published by VMImage identity (ADR-0009). |
SupportsDiskExport | true | true | ExportDisk / GetDiskInfo (export formats: qcow2, raw; clustered: qcow2). |
SupportsDiskImport | true | true | ImportDisk (qcow2, raw, vmdk) with the administrator size limit. |
SupportsExportCompression | true | not reported | qemu-img -c for qcow2 exports. |
| Export / import backends | pvc, s3, nfs | s3, nfs | Relay transfer mode only. |
SupportsClustering | false | true | The Provider answers ListHosts / GetHostInfo. |
SupportedDiskTypes | qcow2, raw, vmdk | same | QEMU formats. VM disks VirtRigaud creates are qcow2. |
SupportedNetworkTypes | virtio, e1000, rtl8139 | same | NIC models advertised by GetCapabilities. |
The VMClass settings for UEFI, secure boot, VT-d, TPM and nested virtualization are not capability flags: they are applied at create (see Firmware, secure boot and platform features).
For the cross-provider matrix and the resilience / observability narrative:
- Provider capabilities matrix
- Operations — Resilience: the CircuitBreaker wraps every libvirt RPC.
- Operations — Observability
Behaviour at a glance: snapshot, revert, clone, reconfigure, disks¶
| Area | libvirt behaviour at v0.4.2 | Code |
|---|---|---|
| Snapshot create | A VM that is off, or a request without memory, gets an external disk-only snapshot; a running VM with snapshotConfig.includeMemory: true gets an internal full-system snapshot (RAM included). includeMemory on an off VM is downgraded to disk-only with a warning. A shut-off VM's CD-ROMs (the cloud-init seed) are ejected for the duration of the snapshot and put back. Synchronous (no task). | server.go (snapshotCreateWith), snapshot_media.go |
| Snapshot revert | spec.snapshot.revertToRef on the VirtualMachine; the VM must be powered off; libvirt 9.9 or later for external snapshots. A disk-only snapshot taken while the VM ran (or by v0.3.11 or earlier) of a VM with a cloud-init CD-ROM is refused on revert. | snapshot_readonly_disks.go, internal/controller/virtualmachine_snapshot_revert.go |
| Snapshot delete | Refused, nothing changed, while another snapshot of the VM is stored in a file the delete would merge away: delete memory snapshots before the disk-only snapshot they sit on. Removes the overlay file libvirt leaves behind. | snapshot_delete_guard.go, snapshot_overlay_cleanup.go |
| Clone | Full clone only; the source VM must be powered off; the clone gets its own cloud-init identity. | clone.go, clone_source_state.go, clone_seed.go |
| Reconfigure | CPU and memory, plus a grow-only primary disk. Result is applied, restart required or failed. | reconfigure.go, reconfigure_online.go |
spec.disks | Not attached. DisksApplied=False/NotSupportedByProvider is set. Only the VMClass diskDefaults.size (the root disk) is applied. | internal/controller/virtualmachine_disks_applied.go |
The sections below give the detail.
RPC support¶
- Validate:
virsh list --all --nameover the SSH connection (the provider also runsvirsh versiononce at startup). A clustered Provider checks instead that its host registry loaded at least one host; per-host reachability is reported throughListHosts/GetHostInfo. - Create: names the domain
<namespace>.<name>, stamps it with its owner, copies or creates the qcow2 root disk in thedefaultpool, builds a private NoCloud seed ISO, defines the domain. The VM is left powered off; theVirtualMachinecontroller powers it on whenspec.powerStateisOn. - Delete: undefines the domain and removes only the files that are provably its own (see Delete).
- Power: start / shutdown / destroy / reboot, idempotent.
- Describe: domain state, VNC URL, IPs (see
status.ips). - Reconfigure: see Reconfigure.
- SnapshotCreate / SnapshotDelete / SnapshotRevert: see Snapshots. All synchronous; no
TaskRefis returned. - Clone: see Cloning.
- ImagePrepare: lazy import of a
source.libvirt.urlimage (single-host only), see Images. - ExportDisk / ImportDisk / GetDiskInfo: back the export and import sides of cross-provider migration.
- Console URL:
Describereturnsvnc://<host>:<port>parsed fromvirsh dumpxml. - ListHosts / GetHostInfo: clustered topology only.
Prerequisites¶
- A libvirt host running
libvirtdwith KVM acceleration (or nested virtualization for development). libvirt 9.9 or later if you want to revert snapshots. - SSH access from the provider pod to the host as a user that can use
qemu:///system, with a POSIX-compatible login shell. - libvirt's
defaultstorage pool at/var/lib/libvirt/images. If the host has nodefaultpool the provider creates one there; adefaultpool at any other path is never modified and creates fail withInvalidSpec. - On the host:
qemu-img(from a QEMU with the CVE-2024-4467 fix: 9.0.2, 8.2.6, 7.2.13 or later, or a backport),genisoimageandisoinfo,curl(for a create that downloads an image from a URL;wgetis no longer used), and for clustered or migration pathsflockandtimeout. - For VMs of a VMClass with
firmware: UEFIorsecurityProfile.secureBoot: an OVMF package (ovmf,edk2-ovmf,qemu-ovmf-x86_64) that installs firmware descriptors in/usr/share/qemu/firmware/(see Firmware, secure boot and platform features). - The cloud-init seed directory (new in v0.4.0, below).
- Optional, for clone/export of VMs that have an external snapshot and for the disk in-use checks to read libvirt's
0600overlays: sudo rules for the exactqemu-imgcommands (VR_DISK_READ,VR_CLONE_COPY,VR_EXPORT_COPY).
Host preparation (packages, SSH user, sudo grants, known_hosts, rate limits, pools) is in Libvirt Host Preparation. The authoritative description of the sudo rules and pool-directory permissions is libvirt clones and the linked-clone dependency.
Seed directory on every host, before you roll the provider (required since v0.4.0)
New cloud-init seeds are built in VIRTRIGAUD_LIBVIRT_SEED_DIR (default /var/lib/libvirt/virtrigaud-seeds). If the directory is missing and the SSH user cannot create it, is not owned by the SSH user, or is readable or writable by group or others, every create on that host fails (and so does every clone of a VM that has a seed) with a retryable refusing to stage cloud-init data. Create it once on each host, including migration target hosts and every host of a clustered Provider:
Details, including hosts shared by Providers with different SSH users: libvirt domain ownership: cloud-init seed directory.
Authentication¶
The libvirt provider reads credentials from the Secret mounted at /etc/virtrigaud/credentials inside the provider pod. The LIBVIRT_USERNAME, LIBVIRT_PASSWORD and LIBVIRT_SSH_PRIVATE_KEY environment variables are read first, and the mounted files are the fallback for any value they leave unset. The Secret keys are read as files; the key names matter:
| Secret key | File path | Used for |
|---|---|---|
username | /etc/virtrigaud/credentials/username | SSH username (also taken from the endpoint URI) |
password | /etc/virtrigaud/credentials/password | Password authentication |
ssh-privatekey | /etc/virtrigaud/credentials/ssh-privatekey | SSH private key in PEM (ignored when password is also present, see below) |
known_hosts | /etc/virtrigaud/credentials/known_hosts | Pinned host keys, see SSH host-key verification |
At least one of password or ssh-privatekey is required. If both are present the password is used, not the key (sshAuthMethods in sshclient.go): put only the key in the Secret unless you mean to use the password.
Provider CR + Secret¶
apiVersion: v1
kind: Secret
metadata:
name: libvirt-credentials
namespace: virtrigaud-system
type: Opaque
stringData:
username: "virtrigaud"
ssh-privatekey: |
-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----
---
apiVersion: infra.virtrigaud.io/v1beta1
kind: Provider
metadata:
name: libvirt-lab
namespace: virtrigaud-system
spec:
type: libvirt
endpoint: "qemu+ssh://virtrigaud@libvirt-host.example.com/system"
credentialSecretRef:
name: libvirt-credentials
runtime:
mode: Remote
image: "ghcr.io/projectbeskar/virtrigaud/provider-libvirt:v0.4.2"
service:
port: 9443
tls:
enabled: true
secretRef:
name: provider-libvirt-tls
insecureSkipVerify: false
A Provider in another namespace than its consumers must also set spec.consumerNamespaceSelector; see Cross-namespace references.
TLS / mTLS (v0.3.7+)¶
Starting in v0.3.7, the manager enforces that every Provider CR has a spec.runtime.service.tls block. A Provider without this block fails to reconcile and its status will show TLSConfigured=False, Reason=TLSBlockMissing: no Deployment is created.
For full mTLS details see Security — mTLS.
spec.runtime.service.tls fields¶
| Field | Type | Description |
|---|---|---|
enabled | bool | Set true to enable mTLS. Set false for plaintext (dev/lab only; audit-flagged). |
secretRef.name | string | Name of a kubernetes.io/tls or Opaque Secret containing tls.crt, tls.key, and ca.crt. |
insecureSkipVerify | bool | Skip server certificate verification. Dev-only; never set in regulated environments. |
TLS material mounts at /etc/virtrigaud/tls inside the provider pod. Both manager and provider pin TLS 1.3. The TLSConfigured status condition reasons are TLSBlockMissing, ExplicitlyDisabled, SecretRefMissing, and Enabled.
SSH host-key verification¶
Host-key verification is on by default (since v0.3.7). A missing known_hosts entry is a hard failure: the provider will not connect. The failure shows in the provider pod log and as Ready=False / ProviderError on the VMs that use the Provider; ProviderAvailable only reflects whether the provider Deployment has a ready replica, so it stays True. The check runs again on every reconnect, so a rotated key is honoured on the next dial.
Seed the file on the operator workstation:
Then include it in the Secret referenced by spec.credentialSecretRef:
apiVersion: v1
kind: Secret
metadata:
name: libvirt-credentials
namespace: virtrigaud-system
type: Opaque
stringData:
username: "virtrigaud"
ssh-privatekey: |
-----BEGIN OPENSSH PRIVATE KEY-----
...
-----END OPENSSH PRIVATE KEY-----
# seed via: ssh-keyscan -H <libvirt-host> >> known_hosts
known_hosts: |
|1|REDACTED_HASH_1=|REDACTED_HASH_2= ssh-ed25519 REDACTED_HOST_PUBLIC_KEY
On a clustered Provider each Host can carry its own credentials and known_hosts through Host.spec.credentialSecretRef.
Escape hatch: disable host-key verification¶
For labs and short migration windows you can disable verification with a provider environment variable. This is audit-flagged and not suitable for regulated environments:
Security note
LIBVIRT_INSECURE_SKIP_HOST_KEY_VERIFICATION=true removes the SSH host-key verification control. Use only in isolated lab environments. Every use is logged.
Endpoint formats¶
| URI | Use |
|---|---|
qemu+ssh://user@host/system | The supported form. The provider runs virsh -c qemu:///system on the host over SSH. |
qemu:///system, qemu+tls://..., qemu+tcp://... | Accepted by the CRD, but the provider then runs a local virsh in the pod. This path is not exercised by the project's tests or lab runs; do not rely on it. |
A Host of a clustered Provider needs a qemu+ssh://[user@]host[:port]/system (or /session) endpoint; the CRD rejects any other form.
Storage¶
All VM disks, imported migration disks and prepared images live in libvirt's default storage pool at /var/lib/libvirt/images. The provider does not select another pool: VMClass diskDefaults.storageClass and spec.disks[].storageClass are not mapped to libvirt pools. A host whose default pool is elsewhere is refused with InvalidSpec and never modified; to put VM storage on shared or faster media, mount it at /var/lib/libvirt/images.
The pool directory must be writable only by root and the provider's SSH user (or sticky). The provider logs a warning otherwise, and a full clone or disk export from a group-writable directory is refused with FailedPrecondition. Check with stat -c '%a %U:%G' /var/lib/libvirt/images.
Every disk VirtRigaud creates is created mode 0640 and given to libvirt-qemu:kvm. The provider's SSH user needs to read VM disks (disk in-use checks, export, full clone): make it a member of kvm, or grant the VR_DISK_READ sudo rule from the host preparation page.
The root disk size comes from the VMClass:
apiVersion: infra.virtrigaud.io/v1beta1
kind: VMClass
metadata:
name: standard
spec:
cpu: 2
memory: "4Gi"
diskDefaults:
type: thin
size: "40Gi"
diskDefaults.size is a floor: a disk already that large is not shrunk. Disks created from an image are qcow2 whatever the VMClass type says.
Networking¶
The provider reads the libvirt block of a VMNetworkAttachment (only the block of the Provider's type is read):
| Attachment field | Libvirt construct | Notes |
|---|---|---|
spec.network.libvirt.networkName | <interface type='network'><source network='...'/> | A libvirt-managed network (for example the NAT default). |
spec.network.libvirt.bridge.name | <interface type='bridge'><source bridge='...'/> | A host bridge. bridge is an object with a name, not a string. Wins over networkName when both are set. |
spec.network.libvirt.model | <model type='...'/> | virtio (default), e1000, e1000e, rtl8139, pcnet, ne2k_pci. |
| none of the above | <interface type='user'> | User-mode networking; libvirt holds no DHCP lease for it. |
Not applied on libvirt: VLAN tags, static IP, gateway and DNS (VirtualMachine.spec.networks[].ipAddress and friends, VMNetworkAttachment.spec.ipAllocation). spec.networks[].macAddress does not reach any provider yet: the manager drops it (ADR-0014). The generated cloud-init network configuration is DHCP on eth0, ens3, enp0s3 and enp1s0. To give a libvirt guest a static address, put a network-config equivalent in your own spec.userData.
Define the network on the host first:
virsh net-define /usr/share/libvirt/networks/default.xml
virsh net-start default
virsh net-autostart default
A NAT network and a bridge:
apiVersion: infra.virtrigaud.io/v1beta1
kind: VMNetworkAttachment
metadata:
name: lan-default
spec:
network:
libvirt:
networkName: default
---
apiVersion: infra.virtrigaud.io/v1beta1
kind: VMNetworkAttachment
metadata:
name: lan-bridge
spec:
network:
libvirt:
bridge:
name: br0
model: virtio
Bridged networking and IP discovery
On a host bridge the LAN's DHCP server answers, not libvirt, so libvirt holds no lease and status.ips stays empty unless the QEMU guest agent runs in the guest. See status.ips.
On a clustered Provider, every attachment contributes a required Host label net.virtrigaud.io/<name>: "true": only a host that carries it is a candidate. The label name is the attachment's networkName, or its bridge name when no networkName is set. Set only one of the two: if both are set, the NIC is attached to the bridge but the VM is scheduled by the networkName label.
Firmware, secure boot and platform features¶
A VMClass chooses the virtual platform of a new VM. These settings take effect when a VM is created: existing domains are not redefined, and a reconfigure does not change a VM's firmware or machine type.
| VMClass setting | Machine type | Firmware | Other |
|---|---|---|---|
| none of the settings below (the default) | pc (i440fx) | BIOS (SeaBIOS) | the domain XML is the same as in earlier releases |
firmware: UEFI | q35 | UEFI (OVMF) without Secure Boot | |
securityProfile.secureBoot: true | q35 | UEFI (OVMF) with Secure Boot, from a variable-store template with keys enrolled | SMM on. Applies whatever firmware says |
securityProfile.vtdEnabled: true | q35 | as selected above (BIOS by default) | emulated Intel IOMMU with interrupt remapping |
securityProfile.tpmEnabled: true | unchanged | unchanged | emulated TPM 2.0 (tpm-tis, swtpm on the host) |
performanceProfile.nestedVirtualization: true | unchanged | unchanged | CPU mode host-passthrough |
apiVersion: infra.virtrigaud.io/v1beta1
kind: VMClass
metadata:
name: secure-medium
spec:
cpu: 4
memory: "8Gi"
firmware: UEFI
securityProfile:
secureBoot: true
firmwareis matched case-insensitively.BIOS,EFIand an unset value select BIOS; onlyUEFIselects UEFI firmware, as on vSphere.- Behaviour change in v0.4.1:
firmware: UEFIis honoured. The provider ignored it in v0.4.0. A VMClass that sets it now creates UEFI VMs, so the image must boot with UEFI (an EFI system partition and a UEFI bootloader) and the host needs an OVMF package. On a host that reports no UEFI firmware the create is refused (Ready=False/ValidationError) where v0.4.0 made a BIOS VM. To keep BIOS VMs, setfirmware: BIOSor leave it unset. List the VMClasses this affects before you roll the provider:
kubectl get vmclass -A -o jsonpath='{range .items[?(@.spec.firmware=="UEFI")]}{.metadata.namespace}/{.metadata.name}{"\n"}{end}'
- Secure boot works. In v0.4.0 a secure boot VMClass produced a q35 domain with the i440fx device layout, which libvirt 10 refuses, and the create was retried every 30 seconds with a fresh image copy each time. The domain now asks libvirt for
<os firmware='efi'>, and libvirt selects an OVMF build from the host's firmware descriptors, one with Secure Boot keys enrolled, so Secure Boot is enforced from the first boot. The provider names no firmware file. In the guest,mokutil --sb-stateprintsSecureBoot enabled. - VT-d and nested virtualization work. libvirt refused the old VT-d XML (
unexpected feature 'iommu'), and nested virtualization required bothvmxandsvm, so it never started. The VM now gets an emulated IOMMU, or the host CPU (host-passthrough). Nested virtualization needs nesting enabled in the host's KVM module (cat /sys/module/kvm_intel/parameters/nestedprintsYor1). See Nested virtualization. - VMs with more than one network interface can be created. On i440fx the second interface took the sound card's PCI slot and libvirt refused the domain.
- q35 device layout. libvirt assigns the PCI addresses, the cloud-init CD-ROM is on SATA (
sda, not IDE), USB isqemu-xhciand video is standard VGA. cloud-init finds the seed by its volume label, so the bus makes no difference to the guest.
Host prerequisites. UEFI and secure boot need a libvirt that supports the <firmware><feature> filters (7.2 or later; tested on libvirt 10.0 with QEMU 8.2), QEMU with the q35 machine type, and an OVMF package that installs firmware descriptors (ovmf on Debian and Ubuntu, edk2-ovmf on Fedora and RHEL, qemu-ovmf-x86_64 on SUSE). Secure boot also needs a descriptor with the secure-boot, enrolled-keys and requires-smm features; on Ubuntu 24.04 ovmf installs one. TPM needs swtpm. To check a host:
ls /usr/share/qemu/firmware/
virsh domcapabilities --machine q35 --arch x86_64 | sed -n '/<os /,/<\/os>/p'
# expect <enum name='firmware'> with <value>efi</value>, and for secure boot
# <enum name='secure'> with <value>yes</value>
On a clustered Provider every host that can receive a UEFI or secure boot VM needs the package: the scheduler does not consider firmware. A VM placed on a host without it is refused (ValidationError) and is re-checked on that host (it keeps its pending host); install the package there, or delete the VM.
Refusals. When libvirt refuses the definition itself (an XML error, an unsupported configuration, no matching OVMF build), the create is a definite refusal: Ready=False/ValidationError, re-checked with a backoff (30 seconds doubling to 10 minutes, or at once when the VM, its VMClass, VMImage or Provider changes), the disk the attempt wrote is removed again, and deleting the VM is not held as CreateOutcomeUnknown. A UEFI create is refused before the image is copied when virsh domcapabilities lists no efi firmware (or, for secure boot, no Secure Boot capable loader).
Delete removes a UEFI VM's own variable store (virsh undefine --nvram); a store at another path is kept and logged.
Trust model. Secure Boot proves only that the boot chain is signed by a key in the variable store's db, and which keys those are depends on the host's OVMF package (on Ubuntu 24.04 that includes Microsoft's third-party UEFI CA, so any boot chain it signed boots). A VMClass cannot choose another template. Details and the security notes (the unauthenticated VNC console can reach the firmware setup): libvirt: firmware, secure boot and platform features.
Limitations. libvirt 10.0 refuses an internal snapshot of a VM with pflash firmware, so a VMSnapshot with includeMemory: true of a running UEFI VM is not taken (disk-only snapshots work, and do not restore UEFI variables such as the boot order). On a clustered Provider whose hosts have different OVMF packages, VMs of one VMClass can get different firmware builds. A change to a VMClass's firmware or securityProfile does not change existing VMs.
Cloud-init (NoCloud seed)¶
Unlike vSphere's guestinfo, libvirt uses the NoCloud datasource: the provider builds an ISO9660 image with user-data and meta-data, attaches it as a read-only CD-ROM and the guest's cloud-init applies it at boot. The code is in internal/providers/libvirt/cloudinit.go.
Seeds are private (v0.4.0). The user-data may carry passwords, keys and tokens, so each seed is built in its own directory inside the seed directory: the ISO is 0600 (libvirt hands it to the qemu user when the domain starts), user-data and meta-data are deleted once the ISO is built, and the SSH user keeps a private copy cloud-init.private.iso that clones read. Earlier releases built seeds under /tmp with the SSH user's umask, readable by any local user of the host. Seeds of existing VMs stay where they are; leftovers from earlier releases need the one-time fix in Upgrading from v0.3.11. The seed holds the user-data in plaintext for as long as the VM exists: exclude the seed directory from host backups or encrypt them. The model is described in Private cloud-init seeds; the host side is in Libvirt Host Preparation.
Breaking change: the default cloud-init no longer creates a user
A libvirt VM created without spec.userData used to get a built-in ubuntu user with a fixed SSH key and passwordless sudo. That is gone. The default seed now sets only the hostname and installs and starts qemu-guest-agent. Supply your own spec.userData with a user and an ssh_authorized_keys entry. VMs already created keep whatever the old default put in the guest: remove it by hand if you do not want it (see Upgrading from v0.3.11).
User-data is passed through unchanged, with these details:
- The seed's
instance-idis the domain name (<namespace>.<name>); a clone getsvirtrigaud-<uid>. spec.userData.cloudInit.inlineandsecretRefare resolved by the manager and merged; the provider writes the result into the seed.- The ISO's
meta-datacarries a DHCP (IPv4 and IPv6) network configuration for the common NIC names. Static addressing is not generated (see Networking).
VM example¶
apiVersion: infra.virtrigaud.io/v1beta1
kind: VMImage
metadata:
name: ubuntu-22-04
spec:
source:
libvirt:
url: "https://cloud-images.example.com/jammy/jammy-server-cloudimg-amd64.img"
format: qcow2
# onMissing: Import (the default) prepares the image on the Provider when
# the first VM needs it. Fail and Wait do not prepare: they hold new VMs
# until something else has prepared the image.
prepare:
onMissing: Import
---
apiVersion: infra.virtrigaud.io/v1beta1
kind: VirtualMachine
metadata:
name: dev-workstation
spec:
providerRef:
name: libvirt-lab
classRef:
name: standard
imageRef:
name: ubuntu-22-04
powerState: "On"
networks:
- name: lan
networkRef:
name: lan-default
userData:
cloudInit:
inline: |
#cloud-config
hostname: dev-workstation
users:
- name: developer
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
ssh_authorized_keys:
- "ssh-ed25519 AAAA..."
packages:
- qemu-guest-agent
runcmd:
- systemctl enable --now qemu-guest-agent
Quote powerState values ("On"): an unquoted On is a boolean in YAML 1.1 and is rejected by the API server.
Install qemu-guest-agent in the guest
The provider adds the guest-agent channel to every domain, but the agent has to run inside the guest. Without it, a guest on a bridge shows no address. If you supply your own spec.userData, install and enable the agent there.
Domain names and ownership¶
A new domain is named <namespace>.<name>, so two namespaces' web VMs are two domains with two disks and two seeds. A name longer than 200 bytes is shortened with a hash. External tooling must read status.id instead of assuming "domain name equals VirtualMachine name"; existing VMs keep their old (bare) names.
Every domain is stamped with its owner (<virtrigaud:owner uid=… namespace=… name=…/> in the domain metadata; read it with virsh metadata <domain> --uri https://virtrigaud.io/xmlns/libvirt/owner/v1). The provider never binds a VirtualMachine to a domain unless the stamp carries that VM's UID: a create that finds a same-named domain with no stamp, another UID, or an unreadable stamp is refused (AlreadyExists/Conflict); a domain with the requester's UID is returned as an idempotent success. A clone never inherits its source's stamp. Names that virsh would resolve as a numeric ID or a UUID are refused. Full rules: libvirt domain ownership.
Images¶
A VMImage with source.libvirt.path names a base image already on the host; one with source.libvirt.url is prepared (downloaded, checked, converted to qcow2) by ImagePrepare.
-
Path images are confined and always copied. The path is resolved on the host and must be a regular file directly inside an allowed image directory, not a disk or backing file of any domain, not a VirtRigaud-reserved name (
*-disk.qcow2,*-migrated.qcow2, seed ISOs, dotfiles), and self-contained (no backing file or external data file). It is copied into the VM's own disk and never attached in place, so VMs never share a disk and deleting a VM never deletes the image. The allowed directories areVIRTRIGAUD_LIBVIRT_IMAGE_DIRS(a comma- or colon-separated list on the provider pod, default/var/lib/libvirt/images); setting it replaces the default:spec: runtime: env: - name: VIRTRIGAUD_LIBVIRT_IMAGE_DIRS value: "/srv/golden-images,/var/lib/libvirt/images"Keep
/var/lib/libvirt/imagesin the list if you use URL images. On a shared pool, keep the image catalog in a separate directory that only administrators write to. - URL images are prepared by identity (ADR-0009). The prepared file is<pool dir>/<namespace>.<name>_<16 hex>.qcow2, read-only (0444), owned by the SSH user, with a stamp file; it is reused only when the stamp matches theVMImageUID and source digest, never by bare name. A source that fails for good (HTTP 4xx, checksum mismatch, unreadable image) showsInvalidSourceinstead of being retried. Downloads are one transfer, bounded in time (spec.prepare.timeout, but at most about 4.5 minutes since v0.4.1: the manager gives the call 5 minutes) and size (VIRTRIGAUD_LIBVIRT_IMAGE_MAX_DOWNLOAD_GIB, default 256). The pool directory must be an allowed image directory on a filesystem with hard links. - A create that carries an image URL (instead of a prepared image, or one that names a predefined template) downloads on the host withcurl, the wayImagePreparedoes (curl -q -K -with the URL on standard input,http,httpsorftponly, the size limit, and a time limit bounded by the call's deadline). Since v0.4.1 the URL is no longer on the host's command line (it waswget <URL>, visible in the process list and audit log), and it is redacted in the provider and manager logs and in errors. Failures are classified: an HTTP 4xx answer (except 408, 425 and 429), a permanentcurlfailure and a scheme other thanhttp,httpsorftpare reported asInvalidArgument, so theVirtualMachineshowsReady=False/ValidationErrorand is re-checked with a backoff. The libvirt host needscurl; if it is missing, the provider log says so. The download is cut off after at most about 4.5 minutes, because the manager gives aCreate5 minutes (less a reserve for the conversion). The same cap applies toImagePreparedownloads, whateverspec.prepare.timeoutsays (the 30-minute default included): prepare large images from a source close to the libvirt host. - The prepare gate applies to import-style sources only: with the defaultonMissing: Importthe image is prepared when the first VM needs it; withFailorWaitnothing is prepared and new VMs wait inWaitingForDependenciesuntil the image has been prepared out of band. A reference-style source (path) is not gated.
Full rules, including the stamp and what is refused: Image preparation.
Snapshots¶
A VMSnapshot names a VM and, optionally, snapshotConfig:
apiVersion: infra.virtrigaud.io/v1beta1
kind: VMSnapshot
metadata:
name: my-vm-pre-upgrade
namespace: default
spec:
vmRef:
name: my-vm
snapshotConfig:
name: pre-upgrade
description: "Full checkpoint before upgrade"
includeMemory: true
| VM state at snapshot time | includeMemory: true | includeMemory: false |
|---|---|---|
| Running | Internal full-system checkpoint: disks and RAM. Needs qcow2 storage. | External disk-only snapshot. The CD-ROM is excluded, but the stored definition still holds the seed, so this snapshot cannot be reverted (below). |
| Off | Downgraded to disk-only with a warning (no RAM to capture). | External disk-only snapshot, taken with the CD-ROMs ejected. This is the revertible kind. |
A VMSnapshot create the provider did not perform (a busy domain, a request that never reached the provider, an unreachable host) is retried since v0.4.1: the VMSnapshot shows Ready=False/ProviderError, with the provider's answer in a SnapshotCreateRetrying event, and the create is sent again after 1 minute, doubling to 10 minutes, for as long as the object exists. In v0.4.0 it ended Failed and you deleted it and created a new one. A cause that does not go away (for example an unreadable disk image: grant VR_DISK_READ) is retried every 10 minutes until you fix it or delete the VMSnapshot. A snapshot libvirt refuses before executing because the VM's configuration does not support it (single-host) fails for good (InvalidArgument): sending it again cannot help.
A snapshot whose overlay file already exists is refused for good (V12). The overlay of a disk-only snapshot is <disk file without its extension>.<snapshot name> (for the VM's own disk <domain>-disk.<snapshot name>). A leftover file of that name comes from the overlays of additional disks (which SnapshotDelete never removes), from overlays that could not be proven safe to remove, and from snapshots deleted by a release before v0.4.0 or by hand. The provider probes the overlay paths before it changes anything and refuses with AlreadyExists: the VMSnapshot ends Failed (single-host and clustered), nothing is created, the message names no host path (the provider log names the disk and the file) and the leftover file is never removed or overwritten. Use another snapshot name, or remove the file after you have checked that no domain, snapshot or internal snapshot on any host that mounts the pool references it (details). A VMSnapshot that v0.4.0 held in SnapshotOutcomeUnknown for this reason stays held until you delete it or confirm its attempt.
The downgrade of includeMemory on an off VM is only a provider log line: no condition or event says it happened. A snapshot of a paused VM is disk-only without the CD-ROM ejection, so it cannot be reverted. Snapshot names are sanitised (letters, digits, _, ., -; at most 64 characters). A memory snapshot is larger and slower than a disk-only one.
Revert¶
Name the snapshot in spec.snapshot.revertToRef on the VirtualMachine. The VM must already be powered off (spec.powerState: "Off"): VirtRigaud never powers a VM off for a revert. Watch status.snapshotRevert and the SnapshotReverted condition (True/Reverted on success, False/RevertFailed on failure, False/WaitingForPowerOff while it waits). The revert is sent at most once per request; to revert to the same snapshot again, remove the field, wait for status.snapshotRevert to disappear, then set it again. After the revert, power the VM on yourself.
kubectl patch vm my-vm --type merge -p '{"spec":{"powerState":"Off"}}'
kubectl patch vm my-vm --type merge \
-p '{"spec":{"snapshot":{"revertToRef":{"name":"my-vm-pre-upgrade"}}}}'
kubectl get vm my-vm -o jsonpath='{.status.snapshotRevert.phase}{"\n"}'
libvirt-specific rules:
- Take the snapshot with the VM powered off if you want to revert it. libvirt reverts an external snapshot by rebuilding the disks from the definition the snapshot stored. A disk-only snapshot that stored the cloud-init CD-ROM makes libvirt rewrite the CD-ROM to an overlay QEMU cannot open (AppArmor), and the VM no longer starts. The provider therefore ejects the CD-ROMs from a shut-off VM's definition while it snapshots, and refuses to revert a snapshot that stored a CD-ROM or read-only disk with media (
RevertFailed, nothing changed, with guidance to take a new snapshot while the VM is off). Snapshots taken while the VM ran, and every snapshot taken by v0.3.11 or earlier, fall in this group. - Memory snapshots of a running VM are internal and are reverted in place; they are not refused.
- libvirt older than 9.9 cannot revert an external snapshot; the provider's error is reported as
RevertFailed. - A revert refused for good (
FailedPrecondition) is not retried and its message carries the provider's guidance instead of a "set it again" hint. - A revert the provider did not perform is retried (v0.4.1). The request goes back to
PendingwithSnapshotReverted=False/RevertNotPerformedand is sent again after 1 minute, doubling to 10 minutes; these answers do not count toward the 5-attempt limit. In v0.4.0 it was re-sent as an unknown outcome and endedFailedwith "the VM may or may not have been reverted" although nothing had changed. Removespec.snapshot.revertToRefto give up. A failed revert is answered by what the provider can prove: not performed (a failure beforevirsh snapshot-revertran, or a busy or wrong-state refusal with the disk sources unchanged),FailedPrecondition(a revert libvirt does not support for the VM),NotFound(a missing snapshot or domain), a terminal failure (libvirt failed during the revert), or "outcome unknown: retry" (the revert may have run). A lost connection mid-revert is no longer reported as a terminal failure. - The revert re-inserts the CD-ROM (the seed) afterwards and checks that no read-only disk was moved; if it cannot, it reports
RevertFailed("reverted, but ...") and keeps a record so the next snapshot, revert, start or reboot of the VM repairs it. An interrupted ejection leaves the seed CD-ROM empty until then: do not start such a VM by hand withvirsh start. - libvirt creates the overlay of a disk-only snapshot and of a revert with mode
0600, and the provider's disk in-use check reads every domain's disk chain. The SSH user therefore needs theVR_DISK_READsudo rule over the pool directory, or the check fails closed with "permission denied reading a disk image".
Full flow, status fields, GitOps notes and the repair procedure for a VM broken by a revert on a v0.4.0 release candidate: Reverting a VirtualMachine to a VMSnapshot.
Delete order with memory snapshots¶
A memory snapshot taken after a disk-only one is stored inside the disk-only snapshot's overlay. Deleting the disk-only snapshot makes libvirt merge that overlay away, and the memory snapshot's data would be lost. Since v0.4.0 the provider refuses that delete before anything changes, answering with the names to delete first. The VMSnapshot keeps its finalizer with Ready=False/DeleteBlocked, shows the provider's answer, and is re-checked with a backoff of up to 5 minutes. Delete the memory snapshots first, then the disk-only snapshot. (virtrigaud.io/force-delete: "true" still removes the VMSnapshot, leaving the snapshot on the host.) Deleting a memory snapshot is never refused by this check.
A memory snapshot that v0.3.11 or a v0.4.0 release candidate already lost keeps only metadata; the provider deletes that metadata when it can prove the data is gone, and otherwise asks you to power the VM off and delete again. The check is not atomic with the delete: do not create a snapshot of a VM while you delete another of its snapshots. See Deleting memory and disk-only snapshots of the same VM.
SnapshotDelete also removes the primary disk's overlay files libvirt leaves behind (<domain>-disk.<snapshot> and the <domain>-disk.<epoch> a revert creates). Overlays of additional data disks and of snapshots deleted before v0.4.0 are not swept.
Cloning¶
A VMClone of a libvirt VM is a full clone: an independent qcow2 copy of the source's primary disk, flattening any backing chain. The clone is named <target namespace>.<target name> and is left powered off unless spec.options.powerOn: true.
apiVersion: infra.virtrigaud.io/v1beta1
kind: VMClone
metadata:
name: clone-from-libvirt-vm
namespace: default
spec:
source:
vmRef:
name: my-source-vm
target:
name: my-cloned-vm
options:
type: FullClone
powerOn: false
- Linked clones are disabled. A linked clone's backing file is the source's live disk and nothing freezes it; powering the source on corrupts the clone. A
VMClonewithtype: LinkedClonefails before any provider call withLinkedCloneUnsupported. Recreate it asFullClone. Linked clones made by an earlier release keep working, and the provider refuses to delete, revert or snapshot their source while they exist (DeleteBlocked,VM_DISK_IN_USE). - The source must be powered off.
qemu-img convertcannot read a disk a running QEMU holds. A running source leaves theVMClonePendingwithReady=False, reasonSourceMustBePoweredOff, re-checked on a backoff and at once when the source's power state changes. To clone a running VM, set itsspec.powerState: "Off", wait for the clone to becomeReady, then power it back on. (vSphere clones running VMs; libvirt does not.) - Clone is same-provider. On a clustered Provider it is routed to the source's host and the clone lands there. For movement between providers see VM Migration.
- A UEFI source's
<nvram>varstore is copied per clone. A clone does not inherit the source's owner stamp; it is stamped with its targetVirtualMachine. - Creating a
VMCloneis read access to the source VM's data. The clone's disk is a full copy, its seed carries the source's user-data (which may hold secrets), and on libvirtspec.customization.userData.cloudInit.inlinebecomes the clone's user-data, run as root on first boot. Grantcreateonvmclonesonly to subjects trusted with read access to every VM in that namespace.
See VM Cloning for VMClone semantics.
Clone identity¶
A full clone copies the source's disk, including cloud-init's record of the instance it last ran as. To stop two VMs sharing SSH host keys, a clone of a VM that boots from a NoCloud seed gets a seed of its own (single host and clustered):
| The clone's seed | |
|---|---|
instance-id | virtrigaud-<target VirtualMachine uid>: a new instance, identical on a retried clone |
local-hostname | spec.customization.hostname (with domain as FQDN) when set, else the target VM's name |
| user-data | spec.customization.userData.cloudInit.inline when set; otherwise the source's, with its top-level hostname: and fqdn: rewritten |
| other files | the source's network-config and vendor-data unchanged |
cloud-init sees a new instance on first boot, regenerates the SSH host keys and re-runs every per-instance module (runcmd, packages, users, ...). It does not regenerate /etc/machine-id (seal the source with cloud-init clean --machine-id if clones need their own), and a static address in the source's network configuration is carried over. User-data keys that undo the new identity (ssh_keys, ssh_deletekeys: false, preserve_hostname: true, manual_cache_clean: true) are logged by name. A source without a seed ISO gives a clone without one. Details: A clone's cloud-init identity.
Reconfigure¶
Reconfigure changes the persistent definition first (--config), then the running domain (--live), and reports one of three results (SupportsHonestReconfigure):
| Result | Meaning | Manager records |
|---|---|---|
| Applied | Every change is in the running domain and the definition (or, for a VM that is off, the definition it boots from) | Reconfiguring=False/ReconcileSuccess |
| Restart required | Persisted, but the running domain cannot take it; takes effect at the next power cycle (off, then on; a guest reboot is not enough) | Reconfiguring=True/RestartRequired |
| Failed | A change could be applied neither way, or the host could not be reached | Reconfiguring=False/ProviderError, retried on a backoff |
Per resource (internal/providers/libvirt/reconfigure.go):
- vCPUs. A count above the definition's maximum raises the maximum first. A running domain then gets
setvcpus --live; if that is refused (a grow beyond the running maximum, or an unplug) the result is restart required. - Memory. A grow within the running
<memory>(a VM created with memory hot-add) moves the balloon target up: applied. A grow beyond it raises<memory>in the definition: restart required. A shrink lowers the definition and, on a running VM, is always restart required. - Disk. Grow-only; the VMClass disk size is a floor. A running VM is grown live with
virsh blockresizeand a best-effort in-guest filesystem grow (guest agent,growpart,resize2fsorxfs_growfs); a stopped VM's volume is resized. A failed grow fails the call before any CPU or memory change. - State. Only a running (or idle) domain is changed live and only a shut-off domain in its definition alone. A paused, suspended-to-RAM, shutting-down or unknown domain is refused with a retryable error.
Errors say what could not be done and never carry the virsh command line, output, a host path or an SSH endpoint.
Hot-add headroom (set before create)¶
Online grow works only for VMs created with headroom. Set the VMClass flags before creating the VM:
apiVersion: infra.virtrigaud.io/v1beta1
kind: VMClass
metadata:
name: hotplug-enabled
spec:
cpu: 4
memory: "8Gi"
performanceProfile:
cpuHotAddEnabled: true # reserve headroom for live vCPU grow
memoryHotAddEnabled: true # reserve headroom for live memory balloon grow
The created domain then has a ceiling of 4x the initial value (vCPUs capped at 64; memory has no hard cap):
<vcpu placement='static' current='4'>16</vcpu> <!-- 4 boot online, 16 ceiling -->
<memory unit='MiB'>32768</memory> <!-- balloon maximum: 4x initial -->
<currentMemory unit='MiB'>8192</currentMemory> <!-- initial guest-visible allocation -->
A VM created without the flags (including every VM created before v0.3.9) reports restart required for any CPU or memory change; to get online reconfigure, recreate it with a class that has the flags. If the in-guest filesystem grow is skipped (no agent, LVM, non-root XFS), finish it in the guest: growpart /dev/vda 1 then resize2fs /dev/vda1 or xfs_growfs /.
A disk-size change alone does not trigger a Reconfigure: the manager sends one when the effective CPU or memory changes, and the disk sizes travel with it.
Power states reported by libvirt: running/idle is On; shut off, in shutdown and crashed are Off; paused and pmsuspended are Suspended; anything else is Unknown. The manager neither powers on nor reconfigures a Suspended or Unknown VM (Ready=False/PowerStateUnmanaged). Full contract: Reconfigure results.
spec.disks are not attached¶
The libvirt provider creates one root disk (sized by the VMClass) and attaches no spec.disks entries. A VirtualMachine with a non-empty spec.disks on a libvirt Provider gets DisksApplied=False, reason NotSupportedByProvider, a Warning event, and (where the VM validating webhook is rendered, which the chart does only with webhooks.enabled=true and manager.maxDiskSize set) an admission warning. The VM runs without the extra disks and Ready is unchanged. spec.disks[].sizeGiB is not applied by Reconfigure either. Remove spec.disks from libvirt VMs.
Delete¶
A VM delete also refreshes the default pool (virsh pool-refresh, best effort: a failure is logged and never fails the delete), so virsh vol-list default stops listing the deleted disk files. A VM whose disks are in another pool leaves that pool stale until its next refresh, and on a clustered Provider whose hosts share the pool directory another host keeps listing the files until its pool is refreshed (run virsh pool-refresh default there). A UEFI VM's own variable store is removed too (see Firmware).
Delete reads the domain definition once; if it cannot, the delete fails retryably with the domain intact. It removes only: the domain's own top-level disk files that are regular files directly inside the default pool or an allowed image directory (never a symlink or its target); the overlay files of its own external-snapshot chain; and its cloud-init seed directory. A base image, another VM's disk, CD-ROM media and anything outside those directories is left in place and logged. While another domain on the host uses the VM's disk (a legacy linked clone, a shared disk), the delete is refused with Ready=False/DeleteBlocked and re-checked every minute. virtrigaud.io/orphan-on-delete: "true" detaches the VirtualMachine without touching the domain. See What Delete removes.
status.ips¶
status.ips lists the VM's addresses, routable only: the manager drops loopback, unspecified, link-local and multicast addresses, entries that are not an IP address, and duplicates, for every provider. Where libvirt gets the addresses depends on the network:
| Guest network | Without the QEMU guest agent | With the agent |
|---|---|---|
libvirt-managed network (NAT default) | The DHCP lease (virsh domifaddr --source lease) is shown | Shown, and replaces the lease list |
Host bridge (libvirt.bridge) | Nothing: libvirt holds no lease. Only an ARP entry the host happens to have (--source arp) can fill it | Shown |
| No attachment (user-mode NIC) | Nothing | Shown |
The sources are tried in the order agent, lease, ARP, and the first with an address wins; while the domain runs, a reachable address from guest-network-get-interfaces replaces the list (at most 16 interfaces and 16 addresses per interface). Anything that took status.ips[0] before v0.4.0 and expected a loopback or link-local entry must read the first reachable address instead. See status.ips.
Console access¶
Describe populates status.consoleURL with a VNC URL extracted from virsh dumpxml. The URL points at the libvirt host's VNC display port:
kubectl get vm dev-workstation -o jsonpath='{.status.consoleURL}'
# vnc://libvirt-host.example.com:5900
Connect with any VNC client (vncviewer, TigerVNC, noVNC).
VNC over the public internet
The libvirt VNC port is unauthenticated by default. Either firewall it to the operator network or front it with a TLS-terminating proxy. Do not expose 5900-590x to the open internet.
Troubleshooting¶
CircuitBreaker open on first deploy¶
If you see:
immediately after a fresh helm install, the breaker has seen repeated RPC failures against the provider and fast-failed further requests rather than spam the SSH endpoint. The most common root cause is an SSH-host issue on the libvirt side, for example kex_exchange_identification: Connection closed by remote host (sshd refusing new connections because of MaxStartups or a per-IP block).
The provider retries transient SSH connection failures with bounded backoff, which absorbs short bursts. It does not paper over a hostile SSH policy: tune the host's MaxStartups and any fail2ban policy (see host preparation).
Triage:
- Open a shell on the libvirt host out of band.
- Inspect
sshdlogs (journalctl -u sshor/var/log/auth.log). - Check for
MaxStartupsexhaustion,fail2banbans on the provider pod's source IP, orAllowUsers/AllowGroupsrestrictions. - Once SSH is healthy the breaker self-recovers (default 60s reset after 10 consecutive failures; see Resilience).
Failures that are the VM's own problem (a refused delete, a disk in use, an unreadable disk image) carry a reason such as VM_DISK_IN_USE or VM_DISK_CHECK_FAILED and are kept out of the breaker.
Every create fails with refusing to stage cloud-init data¶
The seed directory on that host is missing, not owned by the SSH user, or readable or writable by group or others (or sits below a directory writable by others without the sticky bit). Create it as shown in Prerequisites. The provider log names the directory and the problem. A create without spec.userData is refused too, because it still builds a default seed.
qemu-guest-agent not reporting IPs¶
Describe asks the agent for guest-network-get-interfaces. Install and enable it in the guest:
See status.ips for which networks need it.
"the libvirt storage pool "default" on the VM's host is not at /var/lib/libvirt/images"¶
The default pool must be at /var/lib/libvirt/images and the provider never rewrites a pool. Check with virsh pool-dumpxml default | grep '<path>', then mount your storage at that path or fix the pool by hand.
"permission denied" on the libvirt socket / SSH user can't talk to libvirt¶
The SSH user must be in the libvirt group (Debian/Ubuntu) or have polkit rules granting access (RHEL/Fedora). Verify with:
"permission denied reading a disk image"¶
A snapshot, revert, delete or (clustered) create/clone is refused, retryably, because the provider could not read a libvirt overlay (0600, owned by root while the VM is off). Grant the SSH user the VR_DISK_READ sudo rule over the pool directory; see Unreadable disk images.
Ready=False/ValidationError after a create ("libvirt refused the domain definition")¶
libvirt refused the domain XML itself, or no OVMF build matched. The message ends with libvirt's reason. Fix the VMClass (for example firmware: UEFI on a host without an OVMF package), install what the host is missing (see Firmware, secure boot and platform features), or delete the VM. The create is re-sent after 30 seconds, then 1, 2, 4 and 8 minutes, then every 10 minutes, and at once when the VM, its VMClass, VMImage or Provider changes. A refusal that comes from the define, other than a missing UEFI firmware, still copies the image on each re-check and removes the copy again.
A VMSnapshot is Failed with "overlay file ... already exists"¶
A leftover overlay file has the name the new snapshot would use. The file is never removed for you. Use another snapshot name, or remove the file after checking that nothing references it (see Snapshots).
Snapshot fails on a running domain¶
A memory snapshot needs qcow2 storage; raw-on-LVM fails on a running domain. Power the VM off and take a disk-only snapshot, or use qcow2.
Debug logging¶
logLevel sets the provider's LOG_LEVEL.
Known limitations at v0.4.2¶
- A leftover overlay file is never removed for you. A snapshot whose name matches one is refused (see Snapshots).
- Snapshot and revert overlays are
0600, and the disk check needs to read them. libvirt creates<domain>-disk.<snapshot>and<domain>-disk.<epoch>mode0600, owned by root while the VM is off. A snapshot create, revert or delete, and a VM delete (on a clustered Provider also a create and a clone), reads the disk chain of every domain on the host first, and the provider's SSH user must be able to read those overlays: grantVR_DISK_READover the pool directory (an NFS export must not squash root, and must then be dedicated to the Provider's hosts), or repair each new overlay by hand. Without either those operations are refused with "permission denied reading a disk image". Since v0.4.1 aVMSnapshotcreate and a revert are retried every 10 minutes at most until you fix it, and a VM delete and a snapshot delete are retried too (details). - A create from a
source.libvirt.pathimage goes through the disk check too. A single-host create from such an image can be refused, and retried, with "could not verify the image on the libvirt host (transient host error; details are in the provider log)". Fix it as for the snapshots. - UEFI: no memory snapshot, and no revert of UEFI variables (see Firmware).
- Files left by an earlier release's refused create stay. A disk (
<domain>-disk.qcow2) that a create of v0.4.0 or of a v0.4.1 release candidate left on the pool is removed only if a later create of the same VM removes it; remove one yourself after checking that no domain uses it. TheCreateOutcomeUnknownhold of such a VM is released after 10 minutes, or at once by the annotation its message names. - The pool refresh of a VM delete covers the host that ran it (see Delete).
- Minor: libvirt hosts keep the empty per-VM lock files
/tmp/virtrigaud-locks/{export,import,clone}-<domain>.lockafter the VM is gone, and every create logsERROR Command failed: sudo restorecon ...on a host without SELinux, followed by a warning. - Clustered Providers are experimental; host-to-host migration is not implemented (see the clustered guide).
Performance tips¶
- virtio everywhere:
virtioNIC model,virtiodisk bus (the default for VirtRigaud-created disks). - CPU mode
host-passthrough: best raw performance but breaks live migration between dissimilar hosts; usehost-modelif you need portability. - Hot-add requires at-create opt-in: set
cpuHotAddEnabled/memoryHotAddEnabledon the VMClass before creating the VM. - Keep the pool on fast local or well-tuned shared storage mounted at
/var/lib/libvirt/images; the provider does not select other pools.
API reference¶
- Full CRD field reference: Generated CRD docs.
- Provider gRPC contract: Generated gRPC docs.
- Capability matrix (all providers): Capabilities.
Support¶
- Documentation: VirtRigaud Docs
- Issues: GitHub Issues, label
provider/libvirt - libvirt docs: libvirt.org