Updated Branches: refs/heads/4.2 d88ed29a4 -> e8d00451b
CLOUDSTACK-4265 [VMWARE] clustered Management server Unable to perform VM live migration among vmware clusters This is due to a VM on zone wide primary storage not requiring storage migration while migrating across clster. Detecting the storage pool type before allowing normal migration (without storage live migration) of VM across cluster. Signed-off-by: Sateesh Chodapuneedi <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e8d00451 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e8d00451 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e8d00451 Branch: refs/heads/4.2 Commit: e8d00451b9d089406edd928e847370c1e694c4a3 Parents: d88ed29 Author: Sateesh Chodapuneedi <[email protected]> Authored: Fri Aug 16 13:59:28 2013 +0530 Committer: Sateesh Chodapuneedi <[email protected]> Committed: Fri Aug 16 13:59:28 2013 +0530 ---------------------------------------------------------------------- .../src/com/cloud/server/ManagementServerImpl.java | 17 ++++++++--------- .../com/cloud/vm/VirtualMachineManagerImpl.java | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8d00451/server/src/com/cloud/server/ManagementServerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 8b78aed..7a32dc3 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -517,7 +517,6 @@ import com.cloud.storage.GuestOS; import com.cloud.storage.GuestOSCategoryVO; import com.cloud.storage.GuestOSVO; import com.cloud.storage.GuestOsCategory; -import com.cloud.storage.ScopeType; import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.TemplateType; import com.cloud.storage.StorageManager; @@ -1110,7 +1109,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe List<HostVO> allHosts = null; Map<Host, Boolean> requiresStorageMotion = new HashMap<Host, Boolean>(); DataCenterDeployment plan = null; - boolean zoneWideStoragePool = false; + boolean allZoneWideStoragePools = false; if (canMigrateWithStorage) { allHostsPair = searchForServers(startIndex, pageSize, null, hostType, null, srcHost.getDataCenterId(), null, null, null, null, null, null, srcHost.getHypervisorType(), srcHost.getHypervisorVersion()); @@ -1125,9 +1124,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe iterator.remove(); } else { if (srcHost.getHypervisorType() == HypervisorType.VMware || srcHost.getHypervisorType() == HypervisorType.KVM) { - zoneWideStoragePool = checkForZoneWideStoragePool(volumePools); + allZoneWideStoragePools = checkIfAllZoneWideStoragePools(volumePools); } - if ((!host.getClusterId().equals(srcHost.getClusterId()) || usesLocal) && !zoneWideStoragePool) { + if ((!host.getClusterId().equals(srcHost.getClusterId()) || usesLocal) && !allZoneWideStoragePools) { requiresStorageMotion.put(host, true); } } @@ -1189,20 +1188,20 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe suitableHosts, requiresStorageMotion); } - private boolean checkForZoneWideStoragePool(Map<Volume, List<StoragePool>> volumePools) { - boolean zoneWideStoragePool = false; + private boolean checkIfAllZoneWideStoragePools(Map<Volume, List<StoragePool>> volumePools) { + boolean allZoneWideStoragePools = true; Collection<List<StoragePool>> pools = volumePools.values(); List<StoragePool> aggregatePoolList = new ArrayList<StoragePool>(); for (Iterator<List<StoragePool>> volumePoolsIter = pools.iterator(); volumePoolsIter.hasNext();) { aggregatePoolList.addAll(volumePoolsIter.next()); } for (StoragePool pool : aggregatePoolList) { - if (null == pool.getClusterId()) { - zoneWideStoragePool = true; + if (null != pool.getClusterId()) { + allZoneWideStoragePools = false; break; } } - return zoneWideStoragePool; + return allZoneWideStoragePools; } private Map<Volume, List<StoragePool>> findSuitablePoolsForVolumes(VirtualMachineProfile<VMInstanceVO> vmProfile, http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8d00451/server/src/com/cloud/vm/VirtualMachineManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index ee09087..b07b3a9 100755 --- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -1450,6 +1450,21 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac if (fromHost.getClusterId().longValue() != dest.getCluster().getId()) { s_logger.info("Source and destination host are not in same cluster, unable to migrate to host: " + dest.getHost().getId()); throw new CloudRuntimeException("Source and destination host are not in same cluster, unable to migrate to host: " + dest.getHost().getId()); + // This scenario is valid only if all the volumes of VM being migrated are on zone wide storage pools + boolean vmOnZoneWideStoragePool = true; + List<VolumeVO> vmVolumes = _volsDao.findUsableVolumesForInstance(vm.getId()); + for (VolumeVO volume : vmVolumes) { + StoragePoolVO pool = _storagePoolDao.findById(volume.getPoolId()); + if (pool.getScope() != ScopeType.ZONE) { + vmOnZoneWideStoragePool = false; + break; + } + } + // If there is no common storage across the clusters then migration attempt should fail. + if (!vmOnZoneWideStoragePool) { + s_logger.info("Source and destination host are not in same cluster, unable to migrate to host: " + dest.getHost().getId()); + throw new CloudRuntimeException("Source and destination host are not in same cluster, unable to migrate to host: " + dest.getHost().getId()); + } } VirtualMachineGuru<T> vmGuru = getVmGuru(vm);
