Skip to content

Commit 24d1f16

Browse files
committed
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
1 parent a3736f2 commit 24d1f16

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

‎api/src/com/cloud/storage/StoragePool.java‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.util.Date;
2020

21+
import com.cloud.hypervisor.Hypervisor;
2122
import org.apache.cloudstack.api.Identity;
2223
import org.apache.cloudstack.api.InternalIdentity;
2324

@@ -98,10 +99,13 @@ public interface StoragePool extends Identity, InternalIdentity {
9899

99100
Long getPodId();
100101

101-
/**
102-
* @return
103-
*/
104-
String getStorageProviderName();
102+
/**
103+
* @return
104+
*/
105+
String getStorageProviderName();
106+
107+
boolean isInMaintenance();
108+
109+
Hypervisor.HypervisorType getHypervisor();
105110

106-
boolean isInMaintenance();
107111
}

‎server/src/com/cloud/vm/UserVmManagerImpl.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import javax.inject.Inject;
3636
import javax.naming.ConfigurationException;
3737

38+
3839
import org.apache.commons.codec.binary.Base64;
3940
import org.apache.log4j.Logger;
4041

@@ -3720,7 +3721,12 @@ public VirtualMachine vmStorageMigration(Long vmId, StoragePool destPool) {
37203721
throw new InvalidParameterValueException("Data disks attached to the vm, can not migrate. Need to dettach data disks at first");
37213722
}
37223723

3723-
HypervisorType destHypervisorType = _clusterDao.findById(destPool.getClusterId()).getHypervisorType();
3724+
HypervisorType destHypervisorType = destPool.getHypervisor();
3725+
if (destHypervisorType == null) {
3726+
destHypervisorType = _clusterDao.findById(
3727+
destPool.getClusterId()).getHypervisorType();
3728+
}
3729+
37243730
if (vm.getHypervisorType() != destHypervisorType) {
37253731
throw new InvalidParameterValueException("hypervisor is not compatible: dest: " + destHypervisorType.toString() + ", vm: " + vm.getHypervisorType().toString());
37263732
}

0 commit comments

Comments
 (0)