Pearl1594 opened a new pull request, #14926: URL: https://github.com/apache/cloudstack/pull/14926
### Description This PR adds VM snapshot support for the CLVM_NG storage pool type on KVM. Disk-only snapshots work on running and stopped VMs, with UEFI support. Disk+memory snapshots are included as an experimental feature, off by default. Approach CLVM_NG volumes are qcow2 images on LVs in a shared VG. A VM snapshot uses external qcow2 overlays, one LV each. - Taking a snapshot freezes the volume's current LV as a layer and creates a new delta LV on top, with the layer as its backing file. - The agent pre-creates the delta LVs (lvcreate plus qemu-img create -b) before the guest is touched, because libvirt can't create block-backed overlays itself. It then calls snapshotCreateXML with block-typed disks and DISK_ONLY | ATOMIC | NO_METADATA | REUSE_EXT. - Revert creates a new overlay on the snapshot layer. Delete merges the delta into its parent: blockcommit --active --pivot for a running VM, qemu-img commit for a stopped one. - KvmFileBasedStorageVmSnapshotStrategy handles CLVM_NG. DefaultVMSnapshotStrategy now refuses any VM with a CLVM_NG volume, so no internal snapshot is ever taken on an LV. - The storage-specific steps (delta create/delete, sidecars, memory LV) are default methods on StorageAdaptor, implemented by ClvmStorageAdaptor. File-based pools keep their existing behaviour. UEFI The guest NVRAM is saved into a small sidecar LV (vmsnapshot-nvram-<id>). Revert restores it, and delete or expunge removes it. Locking and migration - Layers are exclusive after a snapshot and shared while the VM runs. - Live migration walks the backing chain (ClvmBackingChain) and activates every layer shared on both hosts, then makes them exclusive on the destination. - Stop followed by start on another host releases the old host's layers through ClvmLockTransferCommand DEACTIVATE. - Activating a layer retries for up to 180 s while another host holds its lock. - Merging first makes the parent layer exclusive. Experimental: disk+memory - The memory goes into its own LV (vmsnapshot-memory-<id>), sized at the VM's maximum memory plus 128 MiB. It is written by libvirt's external memory snapshot. - Revert needs a running VM. It creates new overlays, restores the NVRAM for UEFI, and runs virsh restore with the disk paths swapped. - It is gated by the zone setting kvm.clvmng.vmsnapshot.memory.enabled (default false). - External snapshots were chosen over internal ones. Internal snapshots put RAM in the qcow2, so later writes grow the file on a fixed-size LV and can hit ENOSPC. In a benchmark they were also about 5x slower on first overwrite. <!--- Describe your changes in DETAIL - And how has behaviour functionally changed. --> <!-- For new features, provide link to FS, dev ML discussion etc. --> <!-- In case of bug fix, the expected and actual behaviours, steps to reproduce. --> <!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged --> <!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" --> <!-- Fixes: # --> <!--- ******************************************************************************* --> <!--- NOTE: AUTOMATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE DOCUMENTATION. --> <!--- PLEASE PUT AN 'X' in only **ONE** box --> <!--- ******************************************************************************* --> ### 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) - [X] 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 - [X] Major - [ ] Minor #### Bug Severity - [ ] BLOCKER - [ ] Critical - [ ] Major - [ ] Minor - [ ] Trivial ### Screenshots (if appropriate): ### How Has This Been Tested? <!-- Please describe in detail how you tested your changes. --> <!-- Include details of your testing environment, and the tests you ran to --> #### How did you try to break this feature and the system with this change? <!-- see how your change affects other areas of the code, etc. --> <!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) document --> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
