server: set download volume format to qcow2 for KVM volumes (#11198)

This commit is contained in:
Wei Zhou 2025-09-26 20:25:11 +02:00 committed by GitHub
parent 36cfd76ce1
commit 318a4f2b6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -587,7 +587,7 @@ public class KVMStorageProcessor implements StorageProcessor {
try {
final String volumeName = UUID.randomUUID().toString();
final String destVolumeName = volumeName + "." + destFormat.getFileExtension();
final String destVolumeName = volumeName + "." + ImageFormat.QCOW2.getFileExtension();
final KVMPhysicalDisk volume = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(), primaryStore.getUuid(), srcVolumePath);
volume.setFormat(PhysicalDiskFormat.valueOf(srcFormat.toString()));

View File

@ -23,7 +23,9 @@ import java.util.UUID;
import javax.inject.Inject;
import com.cloud.agent.api.storage.DeleteEntityDownloadURLCommand;
import com.cloud.agent.api.to.DataObjectType;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.Upload;
import com.cloud.utils.StringUtils;
@ -72,7 +74,14 @@ public class CloudStackImageStoreDriverImpl extends NfsImageStoreDriverImpl {
}
if (format != null) {
objectNameInUrl = objectNameInUrl + "." + format.getFileExtension();
if (dataObject.getTO() != null
&& DataObjectType.VOLUME.equals(dataObject.getTO().getObjectType())
&& HypervisorType.KVM.equals(dataObject.getTO().getHypervisorType())) {
// Fix: The format of KVM volumes on image store is qcow2
objectNameInUrl = objectNameInUrl + "." + ImageFormat.QCOW2.getFileExtension();
} else {
objectNameInUrl = objectNameInUrl + "." + format.getFileExtension();
}
} else if (installPath.lastIndexOf(".") != -1) {
objectNameInUrl = objectNameInUrl + "." + installPath.substring(installPath.lastIndexOf(".") + 1);
}