From cc18ca79fc6d58fb639ffbb455791caeb021589a Mon Sep 17 00:00:00 2001 From: Sateesh Chodapuneedi Date: Tue, 20 Aug 2013 13:28:14 +0530 Subject: [PATCH] CLOUDSTACK-3851 [VMWare] VM start fails with NPE while trying to retrieve cores per socket If VMware host version is ESXi 4.1 and vCenter version is 5.0 or later, number of cores per socket of a VM running on ESXi 4.1 host would be undefined as it's not supported for versions prior to 5.0. Hence expecting undefined/null value for that and handling it. Signed-off-by: Sateesh Chodapuneedi --- .../src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java index 6c33eea496d..e8cbe8f03d1 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java @@ -2205,7 +2205,8 @@ public class VirtualMachineMO extends BaseMO { if (apiVersion.compareTo("5.0") < 0) { return 1; } - return (Integer)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.numCoresPerSocket"); + Integer coresPerSocket = (Integer) _context.getVimClient().getDynamicProperty(_mor, "config.hardware.numCoresPerSocket"); + return coresPerSocket != null? coresPerSocket : 1; } public int getVirtualHardwareVersion() throws Exception {