This is an automated email from the ASF dual-hosted git repository. weizhouapache pushed a commit to branch 4.23.0-ceph in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 5b24e9d3f322559c4aeecaf9691d7627ab5baaad Author: Abhisar Sinha <[email protected]> AuthorDate: Sat Sep 19 14:10:47 2026 +0530 Fix importVM for use with dummy template (#14195) findByID will fail for dummy template as it is stored in the deleted state. --- server/src/main/java/com/cloud/vm/UserVmManagerImpl.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java index 8fe86231635..a093ed77ec6 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java @@ -9876,6 +9876,15 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (host == null && hypervisorType == HypervisorType.VMware) { throw new InvalidParameterValueException("Unable to import virtual machine with invalid host"); } + if (template == null) { + throw new InvalidParameterValueException("Unable to import virtual machine without a template"); + } + + // Ensure template details are loaded so that commitUserVm can copy them into the VM's details map + if (template instanceof VMTemplateVO) { + VMTemplateVO vmTemplateVO = (VMTemplateVO) template; + _templateDao.loadDetails(vmTemplateVO); + } final long id = _vmDao.getNextInSequence(Long.class, "id"); String instanceName = StringUtils.isBlank(instanceNameInternal) ?
