Repository navigation
Conversation
migrateVirtualMachineWithVolume treated a volume as a linked clone whenever it had a template ID and that template was cached on the volume's current pool. It never looked at the disk. A volume with no backing file, because an offline migrateVolume flattened it or it was created with create.full.clone=true, was then created on the destination on top of the template and copied incrementally. Every region that wasn't allocated in the source file, including ranges the guest had zeroed, read template data afterwards, and the job reported success. Before choosing the linked-clone path for a volume on a file-based pool (NFS, SharedMountPoint or local), the management server now asks the source host for the volume's backing file with GetVolumesOnStorageCommand. A volume without one is migrated as a full clone. If the host can't answer, the migration fails with an error before anything is created for that volume. Fixes apache#14963 Generated-by: Claude Code (claude-mythos-5-2)
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes #14963.
On KVM,
migrateVirtualMachineWithVolumetreats a volume as a linked clone whenever it has a template ID and that template is cached on the volume's current pool (getVolumeBackingFile()readstemplate_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
migrateVolumebetween pools, which flattens it and turns ranges the guest zeroed into holes, or when it was created withcreate.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 infoon the disk is unlikely to migrate it, but I'm happy to switch if reviewers prefer.Fixes: #14963
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Unit tests: seven new tests in
StorageSystemDataMotionStrategyTestforhasBackingFileOnSourceHost(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 inorg.apache.cloudstack.storage.motionpass.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 -Uon the host.write -P 0anddiscard), offlinemigrateVolumeto the other pool, start the VMI didn't repeat the
create.full.clone=truecase 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?
.qcow2suffix that an offline move adds: the host found it.mainthis applies with two small conflicts, both next to the new CLVM code.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.