Repository navigation
StorPool: reject Instance Snapshots with memory - #14788
Conversation
DefaultVMSnapshotStrategy accepts the allocation because StorPool volumes are recorded as QCOW2, but StorPoolVMSnapshotStrategy then takes over the creation and makes a disk-only group snapshot that is saved as DiskAndMemory. Such a snapshot can only be reverted while the VM is running, and StorPool then reverts the volumes under the running VM, which corrupts its data. Reject memory snapshots for VMs with volumes on StorPool during allocation, do not handle allocated DiskAndMemory snapshots in the StorPool strategy, and block reverting existing DiskAndMemory snapshots on StorPool.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14788 +/- ##
============================================
+ Coverage 18.31% 18.32% +0.01%
- Complexity 16642 16658 +16
============================================
Files 5939 5939
Lines 537787 537805 +18
Branches 65932 65937 +5
============================================
+ Hits 98510 98573 +63
+ Misses 428072 428021 -51
- Partials 11205 11211 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
weizhouapache
left a comment
There was a problem hiding this comment.
code lgtm
it affects vms on storpool only
|
@slavkap |
There was a problem hiding this comment.
🔵 Needs a closer look
This critical storage-snapshot change affects strategy selection for new and legacy snapshots, so approval depends on runtime validation of StorPool revert/create behavior and recovery of pre-existing allocated snapshots.
No open issues 🎉
What changed in this PR
This PR prevents unsafe memory-enabled Instance Snapshots for VMs using StorPool and blocks reverting existing snapshots whose metadata indicates memory was captured, avoiding disk reverts under a running VM.
Changes:
- Reject memory snapshot allocation when any VM volume is on StorPool.
- Exclude allocated
DiskAndMemorysnapshots from StorPool strategy handling. - Block reverting existing
DiskAndMemorysnapshots through StorPool. - Add unit and integration coverage for the new behavior.
| File | Description |
|---|---|
| test/integration/plugins/storpool/TestVmSnapshots.py | Adjusts VM root disk sizing and verifies that the API rejects memory snapshots on StorPool. |
| plugins/storage/volume/storpool/src/test/java/org/apache/cloudstack/storage/snapshot/StorPoolVMSnapshotStrategyTest.java | Adds unit tests for allocation handling, strategy selection, and blocked reverts. |
| plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/snapshot/StorPoolVMSnapshotStrategy.java | Adds StorPool memory-snapshot allocation checks, strategy handling, and revert protection. |
Review effort: Lite
Sorry, @weizhouapache, I missed that the Git title got the commit title |
|
Tested in our lab:
|
Description
This PR fixes the VM snapshots on StorPool when memory is selected.
DefaultVMSnapshotStrategy accepts the allocation because StorPool
volumes are recorded as QCOW2, but StorPoolVMSnapshotStrategy then
takes over the creation and makes a disk-only group snapshot that is
saved as DiskAndMemory. Such a snapshot can only be reverted while the
VM is running, and StorPool then reverts the volumes under the running
VM, which corrupts its data.
Reject memory snapshots for VMs with volumes on StorPool during
allocation, do not handle allocated DiskAndMemory snapshots in the
StorPool strategy, and block reverting existing DiskAndMemory snapshots
on StorPool.
Types of changes
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Unit tests, smoke tests and manual testing