Alpha162 opened a new pull request, #14974: URL: https://github.com/apache/cloudstack/pull/14974
### Description This PR fixes #14963. On KVM, `migrateVirtualMachineWithVolume` treats a volume as a linked clone whenever it has a template ID and that template is cached on the volume's current pool (`getVolumeBackingFile()` reads `template_spool_ref`). It never looks at the disk. A volume with no backing file is then created on the destination on top of the template and copied incrementally (`migrateNonSharedInc`), so every region that isn't allocated in the source file reads template data afterwards. The job reports success. A volume has no backing file after an offline `migrateVolume` between pools, which flattens it and turns ranges the guest zeroed into holes, or when it was created with `create.full.clone=true`. #14963 has the details, including a Windows guest that failed to boot after this. With this change, before choosing the linked-clone path for a volume on a file-based pool (NFS, SharedMountPoint or local), the management server asks the source host for the volume's backing file. It uses the existing `GetVolumesOnStorageCommand`, so the agent doesn't change. A volume without a backing file is migrated as a full clone. Other pool types keep the current behaviour. If the host can't answer, or doesn't find the volume, the migration fails with an error before anything is created for that volume. Falling back to a full clone would also be safe for the data, just slower. I chose to stop because a host that can't run `qemu-img info` on the disk is unlikely to migrate it, but I'm happy to switch if reviewers prefer. <!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged --> Fixes: #14963 <!--- ******************************************************************************* --> <!--- 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) - [x] 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 #### Bug Severity - [ ] BLOCKER - [x] Critical - [ ] Major - [ ] Minor - [ ] Trivial ### Screenshots (if appropriate): ### How Has This Been Tested? Unit tests: seven new tests in `StorageSystemDataMotionStrategyTest` for `hasBackingFileOnSourceHost` (backing file present, backing file absent, local and SharedMountPoint pools, a pool type that isn't asked, no answer, a failed answer, volume not found). All 65 tests in `org.apache.cloudstack.storage.motion` pass. Lab: CloudStack 4.22.0.1 on Ubuntu 24.04 (QEMU 8.2.2, libvirt 10.0.0), two KVM hosts in one cluster, two cluster-wide NFS primary pools and the built-in CentOS 5.5 template. This diff applies cleanly to the 4.22.0.1 tag, so I built it there and swapped only this class on the management server. I ran the same steps on a fresh VM with each build, and checked two 1 MiB regions that hold template data by reading them with `qemu-io -r -U` on the host. | Step | 4.22.0.1 | With this PR | |---|---|---| | Live migration with storage of a normal linked clone to the other host and pool | Linked clone, backing file kept | Same. The host check returned the backing file in about 50 ms | | Stop the VM, zero both regions (`write -P 0` and `discard`), offline `migrateVolume` to the other pool, start the VM | No backing file, and both regions are holes that read zeros | Same | | Live migration with storage to the other host and pool | Job succeeds. The template is the backing file again, and both regions read template data | Job succeeds. No backing file, and both regions still read zeros. The management log says the volume "will be migrated as a full clone" | I didn't repeat the `create.full.clone=true` case with this build. Those volumes have no backing file either, so they take the same path as the flattened one. #### How did you try to break this feature and the system with this change? - A volume path with the `.qcow2` suffix that an offline move adds: the host found it. - Data disks and ISO-based volumes have no template ID, so the host isn't asked. - Managed storage, and pools that don't keep volumes as files, skip the check and behave as before. - On `main` this applies with two small conflicts, both next to the new CLVM code. - #14101 changes the same decision for direct-download templates. The two touch nearby lines, so whichever lands second needs a small merge. AI assistance: I used Claude Code and Mythos to help investigate, write and test this change. The tests ran on our own labs, and I've checked the results. -- 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]
