From e9cabd025114ea1cac6ef89e70819e74af99d81e Mon Sep 17 00:00:00 2001 From: Harikrishna Patnala Date: Thu, 19 Nov 2020 11:21:39 +0530 Subject: [PATCH] Fix migrateVMwithVolumes API in case of VMware to address the case when only volume is tried to migrate along with VM. 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 a3da897b250b..56d08a4e088e 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 @@ protected Answer execute(MigrateWithStorageCommand cmd) { } 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 @@ protected Answer execute(MigrateWithStorageCommand cmd) { 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();