diff --git a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java index d229929d886..2604298b3f2 100755 --- a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java @@ -2947,8 +2947,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac * For each one of the volumes we will map it to a storage pool that is available via the target host. * An exception is thrown if we cannot find a storage pool that is accessible in the target host to migrate the volume to. */ - protected void createStoragePoolMappingsForVolumes(VirtualMachineProfile profile, DataCenterDeployment plan, Map volumeToPoolObjectMap, List allVolumes) { - for (Volume volume : allVolumes) { + protected void createStoragePoolMappingsForVolumes(VirtualMachineProfile profile, DataCenterDeployment plan, Map volumeToPoolObjectMap, List volumesNotMapped) { + for (Volume volume : volumesNotMapped) { StoragePoolVO currentPool = _storagePoolDao.findById(volume.getPoolId()); Host targetHost = null; @@ -2958,12 +2958,25 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac executeManagedStorageChecksWhenTargetStoragePoolNotProvided(targetHost, currentPool, volume); if (ScopeType.HOST.equals(currentPool.getScope()) || isStorageCrossClusterMigration(plan.getClusterId(), currentPool)) { createVolumeToStoragePoolMappingIfPossible(profile, plan, volumeToPoolObjectMap, volume, currentPool); - } else { + } else if (shouldMapVolume(profile, volume, currentPool)){ volumeToPoolObjectMap.put(volume, currentPool); } } } + /** + * Returns true if it should map the volume for a storage pool to migrate. + *

+ * Some context: VMware migration workflow requires all volumes to be mapped (even if volume stays on its current pool); + * however, this is not necessary/desirable for the KVM flow. + */ + protected boolean shouldMapVolume(VirtualMachineProfile profile, Volume volume, StoragePoolVO currentPool) { + boolean isManaged = currentPool.isManaged(); + boolean isNotKvm = HypervisorType.KVM != profile.getHypervisorType(); + boolean isNotDatadisk = Type.DATADISK != volume.getVolumeType(); + return isNotKvm || isNotDatadisk || isManaged; + } + /** * Executes the managed storage checks for the volumes that the user has not entered a mapping of . The following checks are performed. *
    diff --git a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/KvmNonManagedStorageDataMotionStrategy.java b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/KvmNonManagedStorageDataMotionStrategy.java index bc951e669f3..237be6c1eff 100644 --- a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/KvmNonManagedStorageDataMotionStrategy.java +++ b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/KvmNonManagedStorageDataMotionStrategy.java @@ -82,21 +82,19 @@ public class KvmNonManagedStorageDataMotionStrategy extends StorageSystemDataMot */ @Override protected StrategyPriority internalCanHandle(Map volumeMap, Host srcHost, Host destHost) { - if (super.internalCanHandle(volumeMap, srcHost, destHost) == StrategyPriority.CANT_HANDLE) { - if (canHandleKVMNonManagedLiveNFSStorageMigration(volumeMap, srcHost, destHost) == StrategyPriority.CANT_HANDLE) { - Set volumeInfoSet = volumeMap.keySet(); - - for (VolumeInfo volumeInfo : volumeInfoSet) { - StoragePoolVO storagePoolVO = _storagePoolDao.findById(volumeInfo.getPoolId()); - - if (!supportStoragePoolType(storagePoolVO.getPoolType())) { - return StrategyPriority.CANT_HANDLE; - } - } - } - return StrategyPriority.HYPERVISOR; + if (super.internalCanHandle(volumeMap, srcHost, destHost) != StrategyPriority.CANT_HANDLE + || canHandleKVMNonManagedLiveNFSStorageMigration(volumeMap, srcHost, destHost) != StrategyPriority.CANT_HANDLE) { + return StrategyPriority.CANT_HANDLE; } - return StrategyPriority.CANT_HANDLE; + + Set volumeInfoSet = volumeMap.keySet(); + for (VolumeInfo volumeInfo : volumeInfoSet) { + StoragePoolVO storagePoolVO = _storagePoolDao.findById(volumeInfo.getPoolId()); + if (!supportStoragePoolType(storagePoolVO.getPoolType())) { + return StrategyPriority.CANT_HANDLE; + } + } + return StrategyPriority.HYPERVISOR; } /**