Skip to content

Commit

Permalink
Fix null pointer exception in restore VM
Browse files Browse the repository at this point in the history
  • Loading branch information
vishesh92 committed Apr 17, 2024
1 parent 44b8d3a commit 27bf825
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -7699,8 +7699,16 @@ public UserVm restoreVM(RestoreVMCmd cmd) throws InsufficientCapacityException,
}
_accountMgr.checkAccess(caller, null, true, vm);

VMTemplateVO template;
if (newTemplateId != null) {
template = _templateDao.findById(newTemplateId);
if (template == null) {
throw new InvalidParameterValueException("Cannot find template with ID " + newTemplateId);
}
} else {
template = _templateDao.findByIdIncludingRemoved(vm.getTemplateId());
}
DiskOffering diskOffering = rootDiskOfferingId != null ? validateAndGetDiskOffering(rootDiskOfferingId, vm, caller) : null;
VMTemplateVO template = _templateDao.findById(newTemplateId);
if (template.getSize() != null) {
String rootDiskSize = details.get(VmDetailConstants.ROOT_DISK_SIZE);
Long templateSize = template.getSize();
Expand Down

0 comments on commit 27bf825

Please sign in to comment.