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 6ef2faaab1c..fd2b97c23ef 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 @@ -2446,6 +2446,22 @@ public class KVMStorageProcessor implements StorageProcessor { template = storagePoolMgr.createPhysicalDiskFromDirectDownloadTemplate(tempFilePath, destTemplatePath, destPool, cmd.getFormat(), cmd.getWaitInMillSeconds()); + String templatePath = template.getPath(); + if (templatePath != null) { + try { + Qcow2Inspector.validateQcow2File(templatePath); + } catch (RuntimeException e) { + try { + Files.deleteIfExists(Path.of(templatePath)); + } catch (IOException ioException) { + s_logger.warn(String.format("Unable to remove file [%s]; consider removing it manually.", templatePath), ioException); + } + + s_logger.error(String.format("The downloaded file [%s] is not a valid QCOW2.", templatePath), e); + return new DirectDownloadAnswer(false, "The downloaded file is not a valid QCOW2. Ask the administrator to check the logs for more details.", true); + } + } + if (!storagePoolMgr.disconnectPhysicalDisk(pool.getPoolType(), pool.getUuid(), destTemplatePath)) { s_logger.warn("Unable to disconnect physical disk at path: " + destTemplatePath + ", in storage pool id: " + pool.getUuid()); } diff --git a/tools/build/build_asf.sh b/tools/build/build_asf.sh index 780473b9df2..07b69ec1502 100755 --- a/tools/build/build_asf.sh +++ b/tools/build/build_asf.sh @@ -64,8 +64,8 @@ echo "Using version: $version" echo "Using source directory: $sourcedir" echo "Using output directory: $outputdir" echo "Using branch: $branch" -if [ "$tag" == "yes" ]; then - if [ "$certid" == "X" ]; then +if [ "$tag" = "yes" ]; then + if [ "$certid" = "X" ]; then echo "Tagging the branch with the version number, and signing the branch with your default certificate." else echo "Tagging the branch with the version number, and signing the branch with certificate ID $certid." @@ -143,7 +143,7 @@ bzip2 $outputdir/apache-cloudstack-$version-src.tar cd $outputdir echo 'armor' -if [ "$certid" == "X" ]; then +if [ "$certid" = "X" ]; then gpg -v --armor --output apache-cloudstack-$version-src.tar.bz2.asc --detach-sig apache-cloudstack-$version-src.tar.bz2 else gpg -v --default-key $certid --armor --output apache-cloudstack-$version-src.tar.bz2.asc --detach-sig apache-cloudstack-$version-src.tar.bz2 @@ -155,7 +155,7 @@ sha512sum apache-cloudstack-$version-src.tar.bz2 > apache-cloudstack-$version-sr echo 'verify' gpg -v --verify apache-cloudstack-$version-src.tar.bz2.asc apache-cloudstack-$version-src.tar.bz2 -if [ "$tag" == "yes" ]; then +if [ "$tag" = "yes" ]; then echo 'tag' cd $sourcedir if [ "$certid" == "X" ]; then @@ -165,7 +165,7 @@ if [ "$tag" == "yes" ]; then fi fi -if [ "$committosvn" == "yes" ]; then +if [ "$committosvn" = "yes" ]; then echo 'committing artifacts to svn' rm -Rf /tmp/cloudstack-dev-dist cd /tmp