From 51034be2708b7d98899c747ca99c5f301885134b Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Fri, 20 Nov 2020 18:08:06 +0530 Subject: [PATCH] Fix migrateVMwithVolumes API in case of multiple volumes on VMware (#4480) Problem: When migrateVMwithVolumes API is tried on a VM with two volumes to migrate to a different host and tried to migrate only one volume, Cloudstack migrates both the Volumes but then marks only one of them migrated. This makes volume inaccessible due to inconsitency in path of volume in cloudstack and vsphere Solution: Set the target datastore in relocate spec properly for each volume --- .../cloud/hypervisor/vmware/resource/VmwareResource.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java index a3da897b250..56d08a4e088 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -4694,7 +4694,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa } diskLocator = new VirtualMachineRelocateSpecDiskLocator(); - diskLocator.setDatastore(morDsAtSource); + diskLocator.setDatastore(morTgtDatastore); Pair diskInfo = getVirtualDiskInfo(vmMo, appendFileType(volume.getPath(), VMDK_EXTENSION)); String vmdkAbsFile = getAbsoluteVmdkFile(diskInfo.first()); if (vmdkAbsFile != null && !vmdkAbsFile.isEmpty()) { @@ -4717,9 +4717,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa diskLocators.add(diskLocator); } } - if (srcHyperHost.getHyperHostCluster().equals(tgtHyperHost.getHyperHostCluster())) { - relocateSpec.getDisk().addAll(diskLocators); - } + relocateSpec.getDisk().addAll(diskLocators); // Prepare network at target before migration NicTO[] nics = vmTo.getNics();