From 24d1f161b8da4cd3dc24693c12eae3f150f79291 Mon Sep 17 00:00:00 2001 From: Edison Su Date: Thu, 27 Mar 2014 15:53:27 -0700 Subject: [PATCH] CLOUDSTACK-5329: fix NPE, in case of zone wide primary storage Conflicts: api/src/com/cloud/storage/StoragePool.java server/src/com/cloud/vm/UserVmManagerImpl.java --- api/src/com/cloud/storage/StoragePool.java | 14 +++++++++----- server/src/com/cloud/vm/UserVmManagerImpl.java | 8 +++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/api/src/com/cloud/storage/StoragePool.java b/api/src/com/cloud/storage/StoragePool.java index 6ede960c1f0..7d541623256 100644 --- a/api/src/com/cloud/storage/StoragePool.java +++ b/api/src/com/cloud/storage/StoragePool.java @@ -18,6 +18,7 @@ package com.cloud.storage; import java.util.Date; +import com.cloud.hypervisor.Hypervisor; import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.InternalIdentity; @@ -98,10 +99,13 @@ public interface StoragePool extends Identity, InternalIdentity { Long getPodId(); - /** - * @return - */ - String getStorageProviderName(); + /** + * @return + */ + String getStorageProviderName(); + + boolean isInMaintenance(); + + Hypervisor.HypervisorType getHypervisor(); - boolean isInMaintenance(); } diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 62f4a535c00..28f23e0ff53 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -35,6 +35,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; + import org.apache.commons.codec.binary.Base64; import org.apache.log4j.Logger; @@ -3720,7 +3721,12 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir throw new InvalidParameterValueException("Data disks attached to the vm, can not migrate. Need to dettach data disks at first"); } - HypervisorType destHypervisorType = _clusterDao.findById(destPool.getClusterId()).getHypervisorType(); + HypervisorType destHypervisorType = destPool.getHypervisor(); + if (destHypervisorType == null) { + destHypervisorType = _clusterDao.findById( + destPool.getClusterId()).getHypervisorType(); + } + if (vm.getHypervisorType() != destHypervisorType) { throw new InvalidParameterValueException("hypervisor is not compatible: dest: " + destHypervisorType.toString() + ", vm: " + vm.getHypervisorType().toString()); }