Skip to content

Commit a82a242

Browse files
committed
Merge branch '4.19'
2 parents b75742d + a2690e9 commit a82a242

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java

+24-4
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
import java.io.FileOutputStream;
2727
import java.io.IOException;
2828
import java.nio.file.Files;
29+
import java.nio.file.Path;
2930
import java.nio.file.Paths;
3031
import java.text.DateFormat;
3132
import java.text.SimpleDateFormat;
33+
import java.util.ArrayList;
3234
import java.util.Arrays;
3335
import java.util.Date;
3436
import java.util.HashMap;
@@ -63,15 +65,19 @@
6365
import org.apache.cloudstack.storage.command.SnapshotAndCopyAnswer;
6466
import org.apache.cloudstack.storage.command.SnapshotAndCopyCommand;
6567
import org.apache.cloudstack.storage.command.SyncVolumePathCommand;
68+
import org.apache.cloudstack.storage.formatinspector.Qcow2Inspector;
6669
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
6770
import org.apache.cloudstack.storage.to.SnapshotObjectTO;
6871
import org.apache.cloudstack.storage.to.TemplateObjectTO;
6972
import org.apache.cloudstack.storage.to.VolumeObjectTO;
73+
import org.apache.cloudstack.utils.cryptsetup.KeyFile;
74+
import org.apache.cloudstack.utils.qemu.QemuImageOptions;
7075
import org.apache.cloudstack.utils.qemu.QemuImg;
7176
import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat;
7277
import org.apache.cloudstack.utils.qemu.QemuImgException;
7378
import org.apache.cloudstack.utils.qemu.QemuImgFile;
7479
import org.apache.cloudstack.utils.qemu.QemuObject;
80+
import org.apache.cloudstack.utils.qemu.QemuObject.EncryptFormat;
7581
import org.apache.commons.collections.MapUtils;
7682
import org.apache.commons.io.FileUtils;
7783
import org.apache.commons.lang3.BooleanUtils;
@@ -80,6 +86,7 @@
8086
import org.apache.commons.lang3.builder.ToStringStyle;
8187
import org.apache.logging.log4j.Logger;
8288
import org.apache.logging.log4j.LogManager;
89+
8390
import org.libvirt.Connect;
8491
import org.libvirt.Domain;
8592
import org.libvirt.DomainInfo;
@@ -134,10 +141,7 @@
134141
import com.cloud.utils.script.Script;
135142
import com.cloud.utils.storage.S3.S3Utils;
136143
import com.cloud.vm.VmDetailConstants;
137-
import org.apache.cloudstack.utils.cryptsetup.KeyFile;
138-
import org.apache.cloudstack.utils.qemu.QemuImageOptions;
139-
import org.apache.cloudstack.utils.qemu.QemuObject.EncryptFormat;
140-
import java.util.ArrayList;
144+
141145

142146
public class KVMStorageProcessor implements StorageProcessor {
143147
protected Logger logger = LogManager.getLogger(getClass());
@@ -2452,6 +2456,22 @@ public Answer handleDownloadTemplateToPrimaryStorage(DirectDownloadCommand cmd)
24522456

24532457
template = storagePoolMgr.createPhysicalDiskFromDirectDownloadTemplate(tempFilePath, destTemplatePath, destPool, cmd.getFormat(), cmd.getWaitInMillSeconds());
24542458

2459+
String templatePath = template.getPath();
2460+
if (templatePath != null) {
2461+
try {
2462+
Qcow2Inspector.validateQcow2File(templatePath);
2463+
} catch (RuntimeException e) {
2464+
try {
2465+
Files.deleteIfExists(Path.of(templatePath));
2466+
} catch (IOException ioException) {
2467+
logger.warn("Unable to remove file [{}]; consider removing it manually.", templatePath, ioException);
2468+
}
2469+
2470+
logger.error("The downloaded file [{}] is not a valid QCOW2.", templatePath, e);
2471+
return new DirectDownloadAnswer(false, "The downloaded file is not a valid QCOW2. Ask the administrator to check the logs for more details.", true);
2472+
}
2473+
}
2474+
24552475
if (!storagePoolMgr.disconnectPhysicalDisk(pool.getPoolType(), pool.getUuid(), destTemplatePath)) {
24562476
logger.warn("Unable to disconnect physical disk at path: " + destTemplatePath + ", in storage pool id: " + pool.getUuid());
24572477
}

tools/build/build_asf.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ echo "Using version: $version"
6464
echo "Using source directory: $sourcedir"
6565
echo "Using output directory: $outputdir"
6666
echo "Using branch: $branch"
67-
if [ "$tag" == "yes" ]; then
68-
if [ "$certid" == "X" ]; then
67+
if [ "$tag" = "yes" ]; then
68+
if [ "$certid" = "X" ]; then
6969
echo "Tagging the branch with the version number, and signing the branch with your default certificate."
7070
else
7171
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
143143

144144
cd $outputdir
145145
echo 'armor'
146-
if [ "$certid" == "X" ]; then
146+
if [ "$certid" = "X" ]; then
147147
gpg -v --armor --output apache-cloudstack-$version-src.tar.bz2.asc --detach-sig apache-cloudstack-$version-src.tar.bz2
148148
else
149149
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
155155
echo 'verify'
156156
gpg -v --verify apache-cloudstack-$version-src.tar.bz2.asc apache-cloudstack-$version-src.tar.bz2
157157

158-
if [ "$tag" == "yes" ]; then
158+
if [ "$tag" = "yes" ]; then
159159
echo 'tag'
160160
cd $sourcedir
161161
if [ "$certid" == "X" ]; then
@@ -165,7 +165,7 @@ if [ "$tag" == "yes" ]; then
165165
fi
166166
fi
167167

168-
if [ "$committosvn" == "yes" ]; then
168+
if [ "$committosvn" = "yes" ]; then
169169
echo 'committing artifacts to svn'
170170
rm -Rf /tmp/cloudstack-dev-dist
171171
cd /tmp

0 commit comments

Comments
 (0)