Skip to content

Commit bba9801

Browse files
widochaturvedia
authored andcommitted
CLOUDSTACK-4423: Do not always append .qcow2 to volume names when copying
Disk images are not always in the QCOW2 format, so don't assume that the filename will always and in .qcow2 (cherry picked from commit 93b40b0) Signed-off-by: animesh <animesh@apache.org>
1 parent 7678ab4 commit bba9801

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ public Answer copyVolumeFromImageCacheToPrimary(CopyCommand cmd) {
319319
DataTO destData = cmd.getDestTO();
320320
DataStoreTO srcStore = srcData.getDataStore();
321321
DataStoreTO destStore = destData.getDataStore();
322+
VolumeObjectTO srcVol = (VolumeObjectTO) srcData;
323+
ImageFormat srcFormat = srcVol.getFormat();
322324
PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO) destStore;
323325
if (!(srcStore instanceof NfsTO)) {
324326
return new CopyCmdAnswer("can only handle nfs storage");
@@ -352,14 +354,16 @@ public Answer copyVolumeFromImageCacheToPrimary(CopyCommand cmd) {
352354
secondaryStoragePool = storagePoolMgr.getStoragePoolByURI(
353355
secondaryStorageUrl + File.separator + volumeDir
354356
);
355-
if (!srcVolumeName.endsWith(".qcow2")) {
357+
if (!srcVolumeName.endsWith(".qcow2") && srcFormat == ImageFormat.QCOW2) {
356358
srcVolumeName = srcVolumeName + ".qcow2";
357359
}
358360
KVMPhysicalDisk volume = secondaryStoragePool
359361
.getPhysicalDisk(srcVolumeName);
360-
storagePoolMgr.copyPhysicalDisk(volume, volumeName,
362+
volume.setFormat(PhysicalDiskFormat.valueOf(srcFormat.toString()));
363+
KVMPhysicalDisk newDisk = storagePoolMgr.copyPhysicalDisk(volume, volumeName,
361364
primaryPool);
362365
VolumeObjectTO newVol = new VolumeObjectTO();
366+
newVol.setFormat(ImageFormat.valueOf(newDisk.getFormat().toString().toUpperCase()));
363367
newVol.setPath(volumeName);
364368
return new CopyCmdAnswer(newVol);
365369
} catch (CloudRuntimeException e) {

0 commit comments

Comments
 (0)