From 3b5f99a7ca530d1a506b6a4237c03978cabdabab Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com> Date: Fri, 19 Feb 2021 06:04:28 -0300 Subject: [PATCH] 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 Co-authored-by: Rohit Yadav --- .../main/java/com/cloud/storage/VolumeApiServiceImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java index 1d442306955..35314e87740 100644 --- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java @@ -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