Skip to content

Commit 187e328

Browse files
author
Anthony Xu
committed
fixed NPE
1 parent a94acc5 commit 187e328

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

‎plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ protected VM createVmFromTemplate(Connection conn, VirtualMachineTO vmSpec, Host
169169
vmr.actionsAfterCrash = Types.OnCrashBehaviour.DESTROY;
170170
vmr.actionsAfterShutdown = Types.OnNormalExit.DESTROY;
171171

172-
Map<String, String> details = vmSpec.getDetails();
173172
if (isDmcEnabled(conn, host) && vmSpec.isEnableDynamicallyScaleVm()) {
174173
//scaling is allowed
175174
vmr.memoryStaticMin = getStaticMin(vmSpec.getOs(), vmSpec.getBootloader() == BootloaderType.CD, vmSpec.getMinRam(), vmSpec.getMaxRam());
@@ -193,18 +192,21 @@ protected VM createVmFromTemplate(Connection conn, VirtualMachineTO vmSpec, Host
193192
vmr.VCPUsMax = 32L;
194193
}
195194

196-
String timeoffset = details.get("timeoffset");
197-
if (timeoffset != null) {
198-
Map<String, String> platform = vmr.platform;
199-
platform.put("timeoffset", timeoffset);
200-
vmr.platform = platform;
201-
}
195+
Map<String, String> details = vmSpec.getDetails();
196+
if ( details != null ) {
197+
String timeoffset = details.get("timeoffset");
198+
if (timeoffset != null) {
199+
Map<String, String> platform = vmr.platform;
200+
platform.put("timeoffset", timeoffset);
201+
vmr.platform = platform;
202+
}
202203

203-
String coresPerSocket = details.get("cpu.corespersocket");
204-
if (coresPerSocket != null) {
205-
Map<String, String> platform = vmr.platform;
206-
platform.put("cores-per-socket", coresPerSocket);
207-
vmr.platform = platform;
204+
String coresPerSocket = details.get("cpu.corespersocket");
205+
if (coresPerSocket != null) {
206+
Map<String, String> platform = vmr.platform;
207+
platform.put("cores-per-socket", coresPerSocket);
208+
vmr.platform = platform;
209+
}
208210
}
209211

210212
vmr.VCPUsAtStartup = (long) vmSpec.getCpus();

0 commit comments

Comments
 (0)