diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java index 92e4570170e3..e4156e5c8119 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java @@ -2455,8 +2455,15 @@ public Answer handleDownloadTemplateToPrimaryStorage(DirectDownloadCommand cmd) template = storagePoolMgr.createPhysicalDiskFromDirectDownloadTemplate(tempFilePath, destTemplatePath, destPool, cmd.getFormat(), cmd.getWaitInMillSeconds()); - String templatePath = template.getPath(); - if (templatePath != null) { + String templatePath = null; + if (template != null) { + templatePath = template.getPath(); + } + if (StringUtils.isEmpty(templatePath)) { + logger.warn("Skipped validation whether downloaded file is QCOW2 for template {}, due to downloaded template path is empty", template.getName()); + } else if (!new File(templatePath).exists()) { + logger.warn("Skipped validation whether downloaded file is QCOW2 for template {}, due to downloaded template path is not valid: {}", template.getName(), templatePath); + } else { try { Qcow2Inspector.validateQcow2File(templatePath); } catch (RuntimeException e) {