$ yum install -y qemu-guest-agent
You can create and delete virtual machine (VM) snapshots for VMs, whether the VMs are powered off (offline) or on (online). You can only restore to a powered off (offline) VM. OpenShift Virtualization supports VM snapshots on the following:
Red Hat OpenShift Data Foundation
Any other cloud storage provider with the Container Storage Interface (CSI) driver that supports the Kubernetes Volume Snapshot API
Online snapshots have a default time deadline of five minutes (5m
) that can be changed, if needed.
Online snapshots are supported for virtual machines that have hot-plugged virtual disks. However, hot-plugged disks that are not in the virtual machine specification are not included in the snapshot. |
To create snapshots of an online (Running state) VM with the highest integrity, install the QEMU guest agent. The QEMU guest agent takes a consistent snapshot by attempting to quiesce the VM’s file system as much as possible, depending on the system workload. This ensures that in-flight I/O is written to the disk before the snapshot is taken. If the guest agent is not present, quiescing is not possible and a best-effort snapshot is taken. The conditions under which the snapshot was taken are reflected in the snapshot indications that are displayed in the web console or CLI. |
A snapshot represents the state and data of a virtual machine (VM) at a specific point in time. You can use a snapshot to restore an existing VM to a previous state (represented by the snapshot) for backup and disaster recovery or to rapidly roll back to a previous development version.
A VM snapshot is created from a VM that is powered off (Stopped state) or powered on (Running state).
When taking a snapshot of a running VM, the controller checks that the QEMU guest agent is installed and running. If so, it freezes the VM file system before taking the snapshot, and thaws the file system after the snapshot is taken.
The snapshot stores a copy of each Container Storage Interface (CSI) volume attached to the VM and a copy of the VM specification and metadata. Snapshots cannot be changed after creation.
With the VM snapshots feature, cluster administrators and application developers can:
Create a new snapshot
List all snapshots attached to a specific VM
Restore a VM from a snapshot
Delete an existing VM snapshot
The VM snapshot feature introduces three new API objects defined as CRDs for managing snapshots:
VirtualMachineSnapshot
: Represents a user request to create a snapshot. It contains information about the current state of the VM.
VirtualMachineSnapshotContent
: Represents a provisioned resource on the cluster (a snapshot). It is created by the VM snapshot controller and contains references to all resources required to restore the VM.
VirtualMachineRestore
: Represents a user request to restore a VM from a snapshot.
The VM snapshot controller binds a VirtualMachineSnapshotContent
object with the VirtualMachineSnapshot
object for which it was created, with a one-to-one mapping.
The qemu-guest-agent
is widely available and available by default in Red Hat
virtual machines. Install the agent and start the service.
To check if your virtual machine (VM) has the QEMU guest agent installed and running, verify that AgentConnected
is listed in the VM spec.
To create snapshots of an online (Running state) VM with the highest integrity, install the QEMU guest agent. The QEMU guest agent takes a consistent snapshot by attempting to quiesce the VM’s file system as much as possible, depending on the system workload. This ensures that in-flight I/O is written to the disk before the snapshot is taken. If the guest agent is not present, quiescing is not possible and a best-effort snapshot is taken. The conditions under which the snapshot was taken are reflected in the snapshot indications that are displayed in the web console or CLI. |
Access the virtual machine command line through one of the consoles or by SSH.
Install the QEMU guest agent on the virtual machine:
$ yum install -y qemu-guest-agent
Ensure the service is persistent and start it:
$ systemctl enable --now qemu-guest-agent
For Windows virtual machines, the QEMU guest agent is included in the VirtIO drivers. Install the drivers on an existing or a new Windows installation.
To check if your virtual machine (VM) has the QEMU guest agent installed and running, verify that AgentConnected
is listed in the VM spec.
To create snapshots of an online (Running state) VM with the highest integrity, install the QEMU guest agent. The QEMU guest agent takes a consistent snapshot by attempting to quiesce the VM’s file system as much as possible, depending on the system workload. This ensures that in-flight I/O is written to the disk before the snapshot is taken. If the guest agent is not present, quiescing is not possible and a best-effort snapshot is taken. The conditions under which the snapshot was taken are reflected in the snapshot indications that are displayed in the web console or CLI. |
Install the VirtIO drivers from the attached SATA CD drive to an existing Windows virtual machine.
This procedure uses a generic approach to adding drivers to Windows. The process might differ slightly between versions of Windows. See the installation documentation for your version of Windows for specific installation steps. |
Start the virtual machine and connect to a graphical console.
Log in to a Windows user session.
Open Device Manager and expand Other devices to list any Unknown device.
Open the Device Properties
to identify the unknown device.
Right-click the device and select Properties.
Click the Details tab and select Hardware Ids in the Property list.
Compare the Value for the Hardware Ids with the supported VirtIO drivers.
Right-click the device and select Update Driver Software.
Click Browse my computer for driver software and browse to the attached SATA CD drive, where the VirtIO drivers are located. The drivers are arranged hierarchically according to their driver type, operating system, and CPU architecture.
Click Next to install the driver.
Repeat this process for all the necessary VirtIO drivers.
After the driver installs, click Close to close the window.
Reboot the virtual machine to complete the driver installation.
Install the VirtIO drivers from the attached SATA CD driver during Windows installation.
This procedure uses a generic approach to the Windows installation and the installation method might differ between versions of Windows. See the documentation for the version of Windows that you are installing. |
Start the virtual machine and connect to a graphical console.
Begin the Windows installation process.
Select the Advanced installation.
The storage destination will not be recognized until the driver is loaded.
Click Load driver
.
The drivers are attached as a SATA CD drive. Click OK and browse the CD drive for the storage driver to load. The drivers are arranged hierarchically according to their driver type, operating system, and CPU architecture.
Repeat the previous two steps for all required drivers.
Complete the Windows installation.
You can create a virtual machine (VM) snapshot by using the web console.
To create snapshots of an online (Running state) VM with the highest integrity, install the QEMU guest agent. The QEMU guest agent takes a consistent snapshot by attempting to quiesce the VM’s file system as much as possible, depending on the system workload. This ensures that in-flight I/O is written to the disk before the snapshot is taken. If the guest agent is not present, quiescing is not possible and a best-effort snapshot is taken. The conditions under which the snapshot was taken are reflected in the snapshot indications that are displayed in the web console or CLI. |
The VM snapshot only includes disks that meet the following requirements:
Must be either a data volume or persistent volume claim
Belong to a storage class that supports Container Storage Interface (CSI) volume snapshots
Click Virtualization → VirtualMachines from the side menu.
Select a virtual machine to open the VirtualMachine details page.
If the virtual machine is running, click Actions → Stop to power it down.
Click the Snapshots tab and then click Take Snapshot.
Fill in the Snapshot Name and optional Description fields.
Expand Disks included in this Snapshot to see the storage volumes to be included in the snapshot.
If your VM has disks that cannot be included in the snapshot and you still wish to proceed, select the I am aware of this warning and wish to proceed checkbox.
Click Save.
You can create a virtual machine (VM) snapshot for an offline or online VM by creating a VirtualMachineSnapshot
object. Kubevirt will coordinate with the QEMU guest agent to create a snapshot of the online VM.
To create snapshots of an online (Running state) VM with the highest integrity, install the QEMU guest agent. The QEMU guest agent takes a consistent snapshot by attempting to quiesce the VM’s file system as much as possible, depending on the system workload. This ensures that in-flight I/O is written to the disk before the snapshot is taken. If the guest agent is not present, quiescing is not possible and a best-effort snapshot is taken. The conditions under which the snapshot was taken are reflected in the snapshot indications that are displayed in the web console or CLI. |
Ensure that the persistent volume claims (PVCs) are in a storage class that supports Container Storage Interface (CSI) volume snapshots.
Install the OpenShift CLI (oc
).
Optional: Power down the VM for which you want to create a snapshot.
Create a YAML file to define a VirtualMachineSnapshot
object that specifies the name of the new VirtualMachineSnapshot
and the name of the source VM.
For example:
apiVersion: snapshot.kubevirt.io/v1alpha1
kind: VirtualMachineSnapshot
metadata:
name: my-vmsnapshot (1)
spec:
source:
apiGroup: kubevirt.io
kind: VirtualMachine
name: my-vm (2)
1 | The name of the new VirtualMachineSnapshot object. |
2 | The name of the source VM. |
Create the VirtualMachineSnapshot
resource. The snapshot controller creates a VirtualMachineSnapshotContent
object, binds it to the VirtualMachineSnapshot
and updates the status
and readyToUse
fields
of the VirtualMachineSnapshot
object.
$ oc create -f <my-vmsnapshot>.yaml
Optional: If you are taking an online snapshot, you can use the wait
command and monitor the status of the snapshot:
Enter the following command:
$