Skip to content

Commit 1efcc19

Browse files
committed
CLOUDSTACK-8941: fix NPE when migrate vm to other zone-wide pools the second time
1 parent f241455 commit 1efcc19

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,10 @@ private void orchestrateStorageMigration(final String vmUuid, final StoragePool
17481748
final HostVO srcHost = _hostDao.findById(srchostId);
17491749
final Long srcClusterId = srcHost.getClusterId();
17501750

1751+
if (destPool == null) {
1752+
throw new CloudRuntimeException("Unable to migrate vm: missing destination storage pool");
1753+
}
1754+
17511755
try {
17521756
stateTransitTo(vm, VirtualMachine.Event.StorageMigrationRequested, null);
17531757
} catch (final NoTransitionException e) {
@@ -1763,7 +1767,7 @@ private void orchestrateStorageMigration(final String vmUuid, final StoragePool
17631767
if (migrationResult) {
17641768
//if the vm is migrated to different pod in basic mode, need to reallocate ip
17651769

1766-
if (!vm.getPodIdToDeployIn().equals(destPool.getPodId())) {
1770+
if (destPool.getPodId() != null && !destPool.getPodId().equals(vm.getPodIdToDeployIn())) {
17671771
final DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), destPool.getPodId(), null, null, null, null);
17681772
final VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vm, null, null, null, null);
17691773
_networkMgr.reallocate(vmProfile, plan);

0 commit comments

Comments
 (0)