From bc760f2f0349842d2f96162b9c8267bab6dae2b5 Mon Sep 17 00:00:00 2001 From: Daniel Augusto Veronezi Salvador Date: Wed, 30 Dec 2020 17:53:13 -0300 Subject: [PATCH 1/2] 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. --- .../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 1d442306955e..de5e54b088f5 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 Volume migrateVolume(MigrateVolumeCmd cmd) { 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 From dff9c56a754e77388e96d4d38c54b33fb45de5cd Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Fri, 19 Feb 2021 14:30:38 +0530 Subject: [PATCH 2/2] Update VolumeApiServiceImpl.java --- .../src/main/java/com/cloud/storage/VolumeApiServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java index de5e54b088f5..35314e877408 100644 --- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java @@ -2174,7 +2174,7 @@ public Volume migrateVolume(MigrateVolumeCmd cmd) { liveMigrateVolume = capabilities.isStorageMotionSupported(); } - if(liveMigrateVolume && HypervisorType.KVM.equals(host.getHypervisorType())) { + 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.");