Copilot commented on code in PR #11786:
URL: https://github.com/apache/cloudstack/pull/11786#discussion_r2410501706
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/MultipathSCSIAdapterBase.java:
##########
@@ -436,6 +437,8 @@ String getExtractCommandForDownloadedFile(String
downloadedTemplateFile, String
return "bunzip2 -c " + downloadedTemplateFile + " > " +
templateFile;
} else if (downloadedTemplateFile.endsWith(".gz")) {
return "gunzip -c " + downloadedTemplateFile + " > " +
templateFile;
+ } else if (downloadedTemplateFile.endsWith(".xz")) {
+ return "xz -d -c " + downloadedTemplateFile + " > " + templateFile;
} else {
throw new CloudRuntimeException("Unable to extract template " +
downloadedTemplateFile);
}
Review Comment:
ZIP is allowed by isTemplateExtractable(), but ".zip" is not handled here,
leading to an exception for ZIP templates. Add a ZIP case similar to other
formats, e.g., return "unzip -p " + downloadedTemplateFile + " > " +
templateFile;
##########
plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/storage/StorPoolStorageAdaptor.java:
##########
@@ -549,6 +550,8 @@ private String getExtractCommandForDownloadedFile(String
downloadedTemplateFile,
return "bunzip2 -c " + downloadedTemplateFile + " > " +
templateFile;
} else if (downloadedTemplateFile.endsWith(".gz")) {
return "gunzip -c " + downloadedTemplateFile + " > " +
templateFile;
+ } else if (downloadedTemplateFile.endsWith(".xz")) {
+ return "xz -d -c " + downloadedTemplateFile + " > " + templateFile;
} else {
throw new CloudRuntimeException("Unable to extract template " +
downloadedTemplateFile);
}
Review Comment:
isTemplateExtractable() treats ZIP as extractable, but
getExtractCommandForDownloadedFile() has no branch for ".zip", which will cause
ZIP files to hit the exception path. Add ZIP handling consistent with other
scripts, for example: return "unzip -p " + downloadedTemplateFile + " > " +
templateFile;
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java:
##########
@@ -193,6 +194,8 @@ public static String
getExtractCommandForDownloadedFile(String downloadedTemplat
return "bunzip2 -c " + downloadedTemplateFile + " > " +
templateUuid;
} else if (downloadedTemplateFile.endsWith(".gz")) {
return "gunzip -c " + downloadedTemplateFile + " > " +
templateUuid;
+ } else if (downloadedTemplateFile.endsWith(".xz")) {
+ return "xz -d -c " + downloadedTemplateFile + " > " + templateUuid;
} else {
throw new CloudRuntimeException("Unable to extract template " +
downloadedTemplateFile);
}
Review Comment:
ZIP archives are flagged as extractable in isTemplateExtractable(), but
there is no handling for ".zip" here, which will cause a runtime exception. Add
a ZIP branch, e.g., return "unzip -p " + downloadedTemplateFile + " > " +
templateUuid;
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java:
##########
@@ -623,6 +624,8 @@ private String getExtractCommandForDownloadedFile(String
downloadedTemplateFile,
return "bunzip2 -c " + downloadedTemplateFile + " > " +
templateFile;
} else if (downloadedTemplateFile.endsWith(".gz")) {
return "gunzip -c " + downloadedTemplateFile + " > " +
templateFile;
+ } else if (downloadedTemplateFile.endsWith(".xz")) {
+ return "xz -d -c " + downloadedTemplateFile + " > " + templateFile;
} else {
throw new CloudRuntimeException("Unable to extract template " +
downloadedTemplateFile);
}
Review Comment:
ZIP is considered extractable in isTemplateExtractable(), but there is no
extraction branch for ".zip" here. Add ZIP extraction support to avoid throwing
for valid ZIP templates, e.g., return "unzip -p " + downloadedTemplateFile + "
> " + templateFile;
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]