cloudstack
cloudstack copied to clipboard
KVM incremental snapshot feature
Description
This PR solves issue #8907.
Currently, when taking a volume snapshot/backup with KVM as the hypervisor, it is always a full snapshot/backup. However, always taking full snapshots of volumes is costly for both the storage network and storage systems. To solve the aforementioned issues, this PR extends the volume snapshot feature in KVM, allowing users to create incremental volume snapshots using KVM as a hypervisor.
To give operators control over which type of snapshot is being created, a new global setting kvm.incremental.snapshot
has been added, which can be changed at zone and cluster scopes; this setting is false by default. Also, the snapshot.delta.max
configuration, used to control the maximum deltas when using XenServer, was extended to also limit the size of the backing chain of snapshots on primary/secondary storage.
This functionality is only available in environments with Libvirt 7.6.0+ and qemu 6.1+. If the kvm.incremental.snapshot
setting is true, and the hosts do not have the required Libvirt and qemu versions, an error will be thrown when trying to take a snapshot. Additionally, this functionality is only available when using file based storage, such as shared mount-point (iSCSI and FC that require a shared mount-point storage file system for KVM such as OCFS2 or GlusterFS), NFS, and local storage. Other storage types for KVM, such as CLVM and RBD, need different approaches to enable incremental backups; therefore, these are not currently supported.
Issue #8907 has more details and flowcharts of all the mapped workflows.
Types of changes
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [X] New feature (non-breaking change which adds functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [X] Enhancement (improves an existing feature and functionality)
- [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
- [ ] build/CI
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
- [X] Major
- [ ] Minor
Bug Severity
- [ ] BLOCKER
- [ ] Critical
- [ ] Major
- [ ] Minor
- [ ] Trivial
Screenshots (if appropriate):
How Has This Been Tested?
Description of tests
During testing, the kvm.incremental.snapshot
setting was changed to true
and the snapshot.delta.max
setting was changed to 3.
Tests with snapshot.backup.to.secondary = false
For the tests in this section, a test VM was created and reused for all tests.
Snapshot creation tests
Test | Result |
---|---|
Access the VM, create any file in it and create volume snapshot 1 while the VM running | Full snapshot created |
Access the VM, create a second file in it, create volume snapshot 2 while the VM running | Incremental snapshot created with correct size and backing chain (snapshot 1) |
Stop the VM and create volume snapshot 3 | Correctly created incremental snapshot |
Start the VM again, create volume snapshot 4 | Full snapshot created |
Migrate the VM and create volume snapshot 5 | Incremental snapshot created from snapshot 4 |
Migrate VM + ROOT volume | Exception |
Snapshot restore tests
Test | Result |
---|---|
Access the VM, delete all previously created files, stop the VM, restore snapshot 1 and start the VM again | Restoration correctly performed, the file created in snapshot creation test 1 was present on the volume |
Access the VM, delete the file restored in snapshot restore test 2, stop the VM, restore snapshot 2 and start the VM again | Restoration correctly performed, the files created in tests 1 and 2 of snapshot creation were present on the volume |
Snapshot removal tests
Test | Result |
---|---|
Delete snapshot 5 | Snapshot deleted and removed from storage |
Delete snapshot 1 | Snapshot deleted and not removed from storage |
Delete snapshots 2 and 3 | Snapshots deleted and removed from storage; furthermore, snapshot 1 was also removed from storage |
Template creation test
# | Test | Result |
---|---|---|
1 | Create template from snapshot 4 and create a VM using the template | Template created correctly, VM had the files created in the original VM |
Tests with snapshot.backup.to.secondary = true
All tests performed in the previous sections were repeated with snapshot.backup.to.secondary = false, in addition, two additional tests were performed. For the tests in this section, a test VM was created and reused for all tests.
Snapshot creation tests
N | Test | Result |
---|---|---|
1 | Migrate the VM + ROOT volume and take snapshot 6 | Migration carried out and full snapshot created |
2 | Stop the VM, migrate the volume and take snapshot 7 | Volume migration performed and incremental snapshot created from snapshot 6 |