Skip to content

StorPool: reject Instance Snapshots with memory - #14788

Merged
sureshanaparti merged 1 commit into
apache:4.22from
storpool:fix-vm-snapshot-with-memory-storpool
Nov 25, 2026
Merged

sureshanaparti merged 1 commit into
apache:4.22from
storpool:fix-vm-snapshot-with-memory-storpool

Conversation

@slavkap

@slavkap slavkap commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

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

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

Unit tests, smoke tests and manual testing

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

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.32%. Comparing base (16238b1) to head (4caf064).

Files with missing lines Patch % Lines
...k/storage/snapshot/StorPoolVMSnapshotStrategy.java 77.77% 1 Missing and 3 partials ⚠️
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     
Flag Coverage Δ
uitests 4.08% <ø> (ø)
unittests 19.42% <77.77%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@weizhouapache weizhouapache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm

it affects vms on storpool only

@sureshanaparti
sureshanaparti requested a lite review from Copilot November 23, 2026 11:08
@weizhouapache

Copy link
Copy Markdown
Member

@slavkap
would you like to add StorPool to the title of the PR ?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 DiskAndMemory snapshots from StorPool strategy handling.
  • Block reverting existing DiskAndMemory snapshots 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

@slavkap slavkap changed the title mgmt: reject Instance Snapshots with memory StorPool: reject Instance Snapshots with memory Nov 23, 2026
@slavkap

slavkap commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@slavkap would you like to add StorPool to the title of the PR ?

Sorry, @weizhouapache, I missed that the Git title got the commit title

@venko-storpool-com

Copy link
Copy Markdown

Tested in our lab:

  • create instance snapshot without memory - OK.
  • restore from instance snapshot without memory, powered off - OK
  • attempt to create an instance snapshot with memory, running VM - OK. Error message: "not supported for volumes on StorPool primary storage"
  • attempt to restore an instance snapshot without memory, running - OK. error message "not allowed for running Instances"
  • attempt to restore a snapshot with memory created with the old version, running VM - OK. Error message "not allowed because it is marked as a Snapshot with memory"
  • attempt to restore a snapshot with memory created with the old version, powered-off VM - OK. Error message "not allowed for stopped Instances"

@sureshanaparti sureshanaparti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm

@sureshanaparti
sureshanaparti merged commit 6489766 into apache:4.22 Nov 25, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants