This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch 4.20
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.20 by this push:
     new 8c4a085a16d Validate the direct downloaded template file format 
(QCOW2) if the template file exists (#10332)
8c4a085a16d is described below

commit 8c4a085a16d50f13222dd4c6d60731e7bd1e57e0
Author: Suresh Kumar Anaparti <[email protected]>
AuthorDate: Thu Feb 13 12:08:57 2025 +0530

    Validate the direct downloaded template file format (QCOW2) if the template 
file exists (#10332)
    
    * Validate the direct downloaded template file format (QCOW2) if the 
template file exists
    
    * string format not required
---
 .../com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

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 5e62671dd22..0a2621b7bd4 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
@@ -2472,8 +2472,15 @@ public class KVMStorageProcessor implements 
StorageProcessor {
 
             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) {

Reply via email to