kvm: Prevent KVM from performing volume migrations of running instances (#4562)

* Prevent KVM from performing volume migrations of running instances

KVM has a limitation to modify instances definitions while they are on running state. Therefore, it is not possible to change volumes backend location easily.

There is a problem in the `migrateVolume` API. This API command ignores that limitation and causes an inconsistence on the database. ACS processes the migrate command, copies the volume to the destination storage, modifies the database and finishes the process with success. However, the running backend is still using the "old volume file".

This PR intends to prevent KVM to perform volumes migrations while KVM instances are in the running state and inform the user of an alternative API command that enables such operation on running instances.

* Update VolumeApiServiceImpl.java

Co-authored-by: Daniel Augusto Veronezi Salvador <daniel@scclouds.com.br>
Co-authored-by: Rohit Yadav <rohit@apache.org>
This commit is contained in:
Daniel Augusto Veronezi Salvador 2021-02-19 06:04:28 -03:00 committed by GitHub
parent c9c1d4a6e5
commit 3b5f99a7ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2173,6 +2173,12 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
if (capabilities != null) {
liveMigrateVolume = capabilities.isStorageMotionSupported();
}
if (liveMigrateVolume && HypervisorType.KVM.equals(host.getHypervisorType())) {
throw new InvalidParameterValueException("KVM does not support volume live migration due to the limited possibility to refresh VM XML domain. " +
"Therefore, to live migrate a volume between storage pools, one must migrate the VM to a different host as well to force the VM XML domain update. " +
"Use 'migrateVirtualMachineWithVolumes' instead.");
}
}
// If vm is running, and hypervisor doesn't support live migration, then return error