|
1 | 1 | // Module included in the following assemblies: |
2 | 2 | // |
3 | | -// * virt/virtual_machines/virtual_disks/virt-managing-offline-vm-snapshots.adoc |
| 3 | +// * virt/virtual_machines/virtual_disks/virt-managing-vm-snapshots.adoc |
4 | 4 |
|
5 | | -[id="virt-creating-offline-vm-snapshot-cli_{context}"] |
6 | | -= Creating an offline virtual machine snapshot in the CLI |
| 5 | +[id="virt-creating-vm-snapshot-cli_{context}"] |
| 6 | += Creating an virtual machine snapshot in the CLI |
7 | 7 |
|
8 | | -You can create a virtual machine (VM) snapshot for an offline VM by creating a `VirtualMachineSnapshot` object. |
| 8 | +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. |
| 9 | + |
| 10 | +[NOTE] |
| 11 | +==== |
| 12 | +To create snapshots of an online (Running state) VM with the highest integrity, install the QEMU guest agent. |
| 13 | +
|
| 14 | +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. |
| 15 | +==== |
9 | 16 |
|
10 | 17 | .Prerequisites |
11 | 18 |
|
12 | 19 | * Ensure that the persistent volume claims (PVCs) are in a storage class that supports Container Storage Interface (CSI) volume snapshots. |
13 | 20 | * Install the OpenShift CLI (`oc`). |
14 | | -* Power down the VM for which you want to create a snapshot. |
| 21 | +* Optional: Power down the VM for which you want to create a snapshot. |
15 | 22 |
|
16 | 23 | .Procedure |
17 | 24 |
|
@@ -42,6 +49,27 @@ of the `VirtualMachineSnapshot` object. |
42 | 49 | $ oc create -f <my-vmsnapshot>.yaml |
43 | 50 | ---- |
44 | 51 |
|
| 52 | +. Optional: If you are taking an online snapshot, you can use the `wait` command and monitor the status of the snapshot: |
| 53 | +.. Enter the following command: |
| 54 | ++ |
| 55 | +[source,terminal] |
| 56 | +---- |
| 57 | +$ kubectl wait my-vm my-vmsnapshot --for condition=Ready |
| 58 | +---- |
| 59 | +.. Verify the status of the snapshot: |
| 60 | +* `InProgress` - The online snapshot operation is still in progress. |
| 61 | +* `Succeeded` - The online snapshot operation completed successfully. |
| 62 | +* `Failed` - The online snapshot operaton failed. |
| 63 | ++ |
| 64 | +[NOTE] |
| 65 | +==== |
| 66 | +Online snapshots have a default time deadline of five (`5`) minutes. If the snapshot does not complete successfully in five minutes, the status is set to `failed`. Afterwards, the file system will be thawed and the VM unfrozen but the status remains `failed` until you delete the failed snapshot image. |
| 67 | +
|
| 68 | +To change the default time deadline, add the `FailureDeadline` attribute to the VM snapshot spec with the time (in minutes) that you want to specify before the snapshot operation times out. |
| 69 | +
|
| 70 | +To set no deadline, you can specify `0`, though this is generally not recommended, as it can result in an unresponsive VM. |
| 71 | +==== |
| 72 | + |
45 | 73 | .Verification |
46 | 74 |
|
47 | 75 | . Verify that the `VirtualMachineSnapshot` object is created and bound with `VirtualMachineSnapshotContent`. The `readyToUse` flag must be set to `true`. |
|
0 commit comments