Skip to content

Commit 318a4f2

Browse files
server: set download volume format to qcow2 for KVM volumes (#11198)
1 parent 36cfd76 commit 318a4f2

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ public Answer copyVolumeFromPrimaryToSecondary(final CopyCommand cmd) {
587587
try {
588588
final String volumeName = UUID.randomUUID().toString();
589589

590-
final String destVolumeName = volumeName + "." + destFormat.getFileExtension();
590+
final String destVolumeName = volumeName + "." + ImageFormat.QCOW2.getFileExtension();
591591
final KVMPhysicalDisk volume = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(), primaryStore.getUuid(), srcVolumePath);
592592
volume.setFormat(PhysicalDiskFormat.valueOf(srcFormat.toString()));
593593

plugins/storage/image/default/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
import javax.inject.Inject;
2424

2525
import com.cloud.agent.api.storage.DeleteEntityDownloadURLCommand;
26+
import com.cloud.agent.api.to.DataObjectType;
2627
import com.cloud.host.dao.HostDao;
28+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
2729
import com.cloud.storage.Upload;
2830
import com.cloud.utils.StringUtils;
2931

@@ -72,7 +74,14 @@ private String createObjectNameForExtractUrl(String installPath, ImageFormat for
7274
}
7375

7476
if (format != null) {
75-
objectNameInUrl = objectNameInUrl + "." + format.getFileExtension();
77+
if (dataObject.getTO() != null
78+
&& DataObjectType.VOLUME.equals(dataObject.getTO().getObjectType())
79+
&& HypervisorType.KVM.equals(dataObject.getTO().getHypervisorType())) {
80+
// Fix: The format of KVM volumes on image store is qcow2
81+
objectNameInUrl = objectNameInUrl + "." + ImageFormat.QCOW2.getFileExtension();
82+
} else {
83+
objectNameInUrl = objectNameInUrl + "." + format.getFileExtension();
84+
}
7685
} else if (installPath.lastIndexOf(".") != -1) {
7786
objectNameInUrl = objectNameInUrl + "." + installPath.substring(installPath.lastIndexOf(".") + 1);
7887
}

0 commit comments

Comments
 (0)