Skip to content

Add support for clvm-ng incremental volume snaps - #14484

Draft
Pearl1594 wants to merge 5 commits into
mainfrom
clvm-ng-bitmap-incsnaps
Draft

Pearl1594 wants to merge 5 commits into
mainfrom
clvm-ng-bitmap-incsnaps

Conversation

@Pearl1594

Copy link
Copy Markdown
Contributor

Description

This PR adds support for incremental volume snapshots for CLVM-NG

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)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Screenshots (if appropriate):

How Has This Been Tested?

  • 5-deep ROOT incremental chain with data written between snapshots - File-level: write and change files in the guest across three snapshots; revert to the first incremental and to a mid-chain incremental, files as expected
  • Incremental snapshot on a stopped VM (ROOT and data volumes)
  • Incremental snapshot on a running VM with the guest writing
  • Restore snapshots to new volumes, byte-identical to the source
  • Create volume from snapshot; template from snapshot, VM boots
  • Delete a middle snapshot: goes Hidden, chain intact
  • Delete the last child
  • Live VM migration, then incremental snapshot
  • Volume migration across VGs, then incremental snapshot and restore
  • Revert a data volume, then snapshot (new full after revert)
  • ROOT revert after VM migration
  • snapshot.delta.max chain rollover
  • Live resize, then snapshot and restore
  • Hourly snapshot policy
  • Snapshot right after boot with the guest writing, then a stopped incremental identical to the LV
  • Forced stop VM, restart on another host, then incremental snaps

How did you try to break this feature and the system with this change?

@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 17.24138% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.92%. Comparing base (d6390bd) to head (d16e1aa).
⚠️ Report is 56 commits behind head on main.

Files with missing lines Patch % Lines
...storage/datastore/db/SnapshotDataStoreDaoImpl.java 0.00% 9 Missing ⚠️
...ud/hypervisor/kvm/storage/KVMStorageProcessor.java 0.00% 7 Missing ⚠️
...om/cloud/storage/snapshot/SnapshotManagerImpl.java 0.00% 7 Missing ⚠️
.../storage/vmsnapshot/StorageVMSnapshotStrategy.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #14484      +/-   ##
============================================
+ Coverage     20.76%   20.92%   +0.16%     
+ Complexity    21903    21149     -754     
============================================
  Files          6496     6057     -439     
  Lines        591612   549567   -42045     
  Branches      72585    73481     +896     
============================================
- Hits         122851   115010    -7841     
+ Misses       455424   421110   -34314     
- Partials      13337    13447     +110     
Flag Coverage Δ
uitests 3.86% <ø> (-0.02%) ⬇️
unittests 22.37% <17.24%> (+0.29%) ⬆️

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.

@Pearl1594

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@Pearl1594 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19694

@Pearl1594
Pearl1594 marked this pull request as ready for review October 23, 2026 13:38
Copilot AI balanced review requested due to automatic review settings October 23, 2026 13:38

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
What changed in this PR

Adds incremental volume snapshot support for CLVM-NG by treating it similarly to KVM/file-based incremental flows and enforcing secondary-storage requirements in the KVM storage processor.

Changes:

  • Enable incremental snapshot payload/flow for StoragePoolType.CLVM_NG when kvmIncrementalSnapshot is enabled.
  • Adjust snapshot-to-secondary handling to avoid double-backup for CLVM-NG incremental snapshots.
  • Add CLVM-NG incremental validation in KVM snapshot creation (requires secondary storage; supports live/paused cases).
File Description
server/​src/​main/​java/​com/​cloud/​storage/​snapshot/​SnapshotManagerImpl.java Enables CLVM-NG to participate in the incremental snapshot/secondary-store allocation flow and adjusts backup behavior accordingly.
plugins/​hypervisors/​kvm/​src/​main/​java/​com/​cloud/​hypervisor/​kvm/​storage/​KVMStorageProcessor.java Adds CLVM-NG incremental snapshot checks and routes live/stopped snapshot handling through incremental paths using secondary storage.

Review effort: Lite

Comment on lines +2120 to 2123
if (isClvmNgIncremental) {
logger.info("Taking incremental snapshot of CLVM_NG volume [{}] using QCOW2 backup to secondary storage.", volume.getName());
newSnapshot = takeIncrementalVolumeSnapshotOfStoppedVm(snapshotTO, primaryPool, secondaryPool,
imageStoreTo.getUrl(), snapshotName, volume, conn, cmd.getWait());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is a false positive - there's a guard before. So no NPE.


StoragePoolType poolType = volume.getStoragePoolType();
boolean isClvmNgIncrementalCandidate = StoragePoolType.CLVM_NG == poolType && kvmIncrementalSnapshot.valueIn(clusterId);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed by a different fix. CLVM_NG incremental is now gated on backupSnapToSecondary, so it falls back to the primary LVM path instead of failing.

}
boolean isLiveClvmNgIncremental = isClvmNgIncremental && (DomainInfo.DomainState.VIR_DOMAIN_RUNNING.equals(state) || DomainInfo.DomainState.VIR_DOMAIN_PAUSED.equals(state));
if ((DomainInfo.DomainState.VIR_DOMAIN_RUNNING.equals(state) && !primaryPool.isExternalSnapshot()) || isLiveClvmNgIncremental) {
if (snapshotTO.isKvmIncrementalSnapshot()) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not required.

@JoaoJandre JoaoJandre 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, did not test it

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@nvazquez

nvazquez commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Hi @Pearl1594 can you please address the conflicts?

Copilot AI balanced review requested due to automatic review settings November 1, 2026 21:34

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.


if (archiveSnapshotToSecondary) {
if (!isKvmAndFileBasedStorage) {
if (!isKvmAndFileBasedStorage && !isClvmNgIncrementalCandidate) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

addressed.

Comment on lines +1685 to 1686
if (!isKvmAndFileBasedStorage && !isClvmNgIncrementalCandidate) {
backupSnapshotToSecondary(payload.getAsyncBackup(), snapshotStrategy, snapshotOnPrimary, payload.getZoneIds(), payload.getStoragePoolIds());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

following the same as file based kvm path

}

if (isKvmAndFileBasedStorage && kvmIncrementalSnapshot.valueIn(clusterId)) {
if ((isKvmAndFileBasedStorage || StoragePoolType.CLVM_NG == poolType) && kvmIncrementalSnapshot.valueIn(clusterId)) {
@Pearl1594

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@Pearl1594 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

🔴 Test Coverage Grade: D — Marginal

Metric Value
Line coverage 25.87%
Branch coverage 21.09%

Grade Scale

Grade Line Coverage Meaning
🟢 A ≥ 80% Excellent - this code sleeps well at night 😴
🟡 B 60-79% Good - almost there, don't stop now 😉
🟠 C 40-59% Acceptable - your code is wearing a seatbelt, but no airbags 😬
🔴 D 20-39% Marginal - boldly shipping where no test has gone before 🖖
⛔ F < 20% Failing - tests? what tests? 🔥

Branch coverage is shown as a secondary signal. Grade is determined by line coverage.
View full Actions run

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✖️ suse15. SL-JID 19869

@RosiKyu

RosiKyu commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@Pearl1594 a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@Pearl1594
Pearl1594 marked this pull request as draft November 12, 2026 20:50
@Pearl1594

Copy link
Copy Markdown
Contributor Author

@RosiKyu I found an issue with bitmap removal for a stopped VM and when the disks have moved:
Bitmap removal picks its host from the VM (its host, or its last host if stopped) and does not ask the CLVM manager which host holds the volume's lock. When the lock is on a different host, qemu-img bitmap --remove runs where the LV is inactive and the snapshot delete fails. Ive added a fix for it. SOrry abt that.

@Pearl1594

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@Pearl1594 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20040

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-17568)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 68172 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr14484-t17568-kvm-ol8.zip
Smoke tests completed. 156 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_uservm_host_control_state Failure 17.36 test_host_control_state.py

@RosiKyu

RosiKyu commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

@Pearl1594 I've re-tested, the bitmap removal fix works: with the VM stopped and its disk moved so it is active on another host, the snapshot delete succeeds and goes to the host holding the disk. More regression and negative tests passed too: detached disk, plain CLVM, revert and volume/template from a snapshot with the disk on another host than the stopped VM's last host, VM moved between hosts, two snapshots at once, snapshot while the VM starts, host reboot.

One problem found: after deleting a snapshot that has a newer snapshot after it and restarting the VM, every new snapshot of the CLVM_NG disk fails with only "internal error". Moving the disk to the other CLVM_NG pool does not help. Reproduced 3 out of 3 times, with the VM running or stopped at the time of the delete.

Steps to reproduce:

  1. VM V running, with data disk D on a CLVM_NG pool. Take snapshots S1, S2, S3 of D.
  2. Delete S2.
  3. Stop V and start it again.
  4. Take a snapshot of D: it fails, and so does every later snapshot of D. Expected: it succeeds (as an incremental on S3, or as a new full).

On the start in step 3 the host cannot restore the checkpoint of S3 because its parent (S2) is gone, so the snapshot in step 4 cannot find it.

Lab mapping: host H = 10.0.x.Y (kvm4), VM V = vm-t1 (i-2-8-VM), disk D = t3-vol-from-r2 (9c4e4023-95ac-462d-b19d-a2e65b2ff60e), S1/S2/S3 = F-1/F-2/F-3, S2 checkpoint = 608c158e-6241-4bfa-a72e-4b4d9f731d73, S3 checkpoint = ae9e8d14-b2d3-4c86-bb44-81499cbbf314.

API, steps 1 to 4: S2 deleted, VM restarted, the next snapshot fails

  F-1: jobstatus 1
  F-2: jobstatus 1
  F-3: jobstatus 1
  -- delete F-2 (middle), VM running, 17:18:11
  delete F-2: jobstatus 1 {"success": true}
  stop vm-t1: jobstatus 1
  start vm-t1: jobstatus 1
  vm-t1: Running kvm4
  -- snapshot F-4 after the restart, 17:19:05
  F-4: jobstatus 2 "errortext": "Failed to create Snapshot due to an internal error creating Snapshot for volume 9c4e4023-95ac-462d-b19d-a2e65b2ff60e"

Host H, steps 3 and 4: the checkpoint of S3 cannot be restored because S2 is gone, then the snapshot fails (the first line is the same problem on another disk from an earlier run)

[root@ref-trl-12929-k-mol8-rositsa-kyuchukova-kvm4 ~]# grep -E 'for moment .* not found|for incremental backup of disk .* not found' /var/log/cloudstack/agent/agent.log | grep encountered | grep "2026-11-17 17:19"
2026-11-17 17:19:02,138 WARN  [utils.script.Script] (AgentRequest-Handler-2:[]) (logid:168923cf) Process [4118] for command [/bin/bash -c virsh checkpoint-create --domain i-2-8-VM --xmlfile /mnt/5ad757a4-e9f9-3a5c-8dc7-0e0ea7bc5136/checkpoints/2/19/a94cc206-e5e9-431f-aae4-fcdda50052dd --redefine ] encountered the error: [error: invalid argument: parent 766c7f8d-2a66-45e4-acc1-5665e6943254 for moment a94cc206-e5e9-431f-aae4-fcdda50052dd not found].
2026-11-17 17:19:03,492 WARN  [utils.script.Script] (AgentRequest-Handler-2:[]) (logid:168923cf) Process [4155] for command [/bin/bash -c virsh checkpoint-create --domain i-2-8-VM --xmlfile /mnt/5ad757a4-e9f9-3a5c-8dc7-0e0ea7bc5136/checkpoints/2/22/ae9e8d14-b2d3-4c86-bb44-81499cbbf314 --redefine ] encountered the error: [error: invalid argument: parent 608c158e-6241-4bfa-a72e-4b4d9f731d73 for moment ae9e8d14-b2d3-4c86-bb44-81499cbbf314 not found].
2026-11-17 17:19:08,538 WARN  [utils.script.Script] (AgentRequest-Handler-5:[]) (logid:3bd71886) Process [4174] for command [/bin/bash -c virsh backup-begin --domain i-2-8-VM --backupxml /tmp/cloudstack/backupXMLs/a78027f1-c530-49e8-aaf1-23be517a74b9 --checkpointxml /tmp/cloudstack/checkpointXMLs/a78027f1-c530-49e8-aaf1-23be517a74b9 ] encountered the error: [error: Domain checkpoint not found: Checkpoint 'ae9e8d14-b2d3-4c86-bb44-81499cbbf314' for incremental backup of disk 'vdf' not found].

@Pearl1594

Copy link
Copy Markdown
Contributor Author

Thanks for testing @RosiKyu . This seems to be an issue that also exists on NFS/ file based stgs. I will push a fix today. Sorry for the delay. Thanks!

@Pearl1594

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@Pearl1594 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20132

@RosiKyu

RosiKyu commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

LGTM

@Pearl1594 I retested the fix for incremental snapshots failing after a middle snapshot is deleted and the VM is restarted (3aa5dc3), with the PR packages on a 4-host KVM cluster with NFS and CLVM_NG pools, kvm.incremental.snapshot=true.

  • I confirmed first that the problem is not from this PR: on a clean 24.0 build the same steps fail on NFS too.
  • With the fix: snapshot S1, S2, S3, delete S2, stop and start the VM, the next snapshots succeed on NFS and on CLVM_NG, with the VM running or stopped at the delete.
  • Upgrade: a chain broken on 24.0 (NFS) works again after upgrading to the PR packages, once the VM is stopped and started.
  • Other cases now work too: deleting the first snapshot or two middle ones, then restarting. On 24.0 they broke the chain the same way.
  • Regression, same result as on 24.0 (NFS and CLVM_NG): restart with no deleted snapshots, deleting the last snapshot, deleting all snapshots, volume, template and revert from a snapshot, live migration, VM snapshot allowed with no volume snapshots and refused while incremental snapshots exist, kvm.incremental.snapshot=false.

Lab mapping: VM V = vm-ha-nfs (NFS root disk D1 a30650c9-ef44-43ca-95b5-8593aca1bc2b), VM W = vm-t1 (CLVM_NG root disk D2 b115e913-4dc1-46e4-9a99-1e9e32619d2d).

Clean 24.0 build, NFS disk D1: after deleting the middle snapshot and restarting V, the next snapshots fail

  NF-1: jobstatus 1 
  NF-2: jobstatus 1 
  NF-3: jobstatus 1 
  -- delete NF-2 (middle), 15:38:32
  delete NF-2: jobstatus 1 "success": true 
  stop vm-ha-nfs: jobstatus 1 
  start vm-ha-nfs: jobstatus 1  Running ref-trl-12929-k-mol8-rositsa-kyuchukova-kvm4 i-2-7-VM
  -- snapshot NF-4 after the restart, 15:40:53
  NF-4: jobstatus 2 "errortext": "Failed to create Snapshot due to an internal error creating Snapshot for volume a30650c9-ef44-43ca-95b5-8593aca1bc2b" 
  NF-5: jobstatus 2 "errortext": "Failed to create Snapshot due to an internal error creating Snapshot for volume a30650c9-ef44-43ca-95b5-8593aca1bc2b" 

PR packages, NFS disk D1, V running at the delete: the next snapshots succeed

  PN-1: jobstatus 1 
  PN-2: jobstatus 1 
  PN-3: jobstatus 1 
  -- delete PN-2 (middle) 16:29:41
  delete PN-2: jobstatus 1 "success": true 
  stop vm-ha-nfs: jobstatus 1 
  start vm-ha-nfs: jobstatus 1  Running kvm1
  -- snapshots after the restart 16:30:37
  PN-4: jobstatus 1 
  PN-5: jobstatus 1 

PR packages, CLVM_NG disk D2, W running at the delete: the next snapshots succeed

  PG-1: jobstatus 1 
  PG-2: jobstatus 1 
  PG-3: jobstatus 1 
  -- delete PG-2 (middle) 16:31:43
  delete PG-2: jobstatus 1 "success": true 
  stop vm-t1: jobstatus 1 
  start vm-t1: jobstatus 1  Running kvm4
  -- snapshots after the restart 16:32:49
  PG-4: jobstatus 1 
  PG-5: jobstatus 1 

PR packages, CLVM_NG disk D2, W stopped at the delete: the next snapshots succeed

  PS-1: jobstatus 1 
  PS-2: jobstatus 1 
  PS-3: jobstatus 1 
  stop vm-t1: jobstatus 1 
  -- delete PS-2 (middle), VM stopped 16:34:26
  delete PS-2: jobstatus 1 "success": true 
  start vm-t1: jobstatus 1  Running kvm4
  -- snapshots after the start 16:34:47
  PS-4: jobstatus 1 
  PS-5: jobstatus 1 

@RosiKyu

RosiKyu commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

@Pearl1594 could you please review the copilot comments? Thank you!

@RosiKyu

RosiKyu commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@RosiKyu a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-17613)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 65094 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr14484-t17613-kvm-ol8.zip
Smoke tests completed. 157 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@Pearl1594

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@Pearl1594 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
10.7% Coverage on New Code (required ≥ 40%)

See analysis details on SonarQube Cloud

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20176

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20177

This branch has not been deployed

No deployments
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.

6 participants