Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,32 @@ private VolumeVO createVolumeOnStoragePool(Long volumeId, Long storageId) throws
if (createVolumeResult.isFailed()) {
throw new CloudRuntimeException("Volume creation on storage failed: " + createVolumeResult.getResult());
}
return _volsDao.findById(volumeInfo.getId());
VolumeVO volVO = _volsDao.findById(volumeInfo.getId());
if (volVO.getFormat() == null) {
HypervisorType hyperType = storagePool.getHypervisor();
ImageFormat format = getSupportedImageFormatForHypervisor(hyperType);
if (format != null) {
Comment on lines +1104 to +1106
volVO.setFormat(format);
_volsDao.update(volVO.getId(), volVO);
}
}
Comment thread
sathvikaragi marked this conversation as resolved.
return volVO;
Comment thread
sathvikaragi marked this conversation as resolved.
}

private ImageFormat getSupportedImageFormatForHypervisor(HypervisorType hyperType) {
if (hyperType == HypervisorType.XenServer) {
return ImageFormat.VHD;
} else if (hyperType == HypervisorType.KVM) {
return ImageFormat.QCOW2;
} else if (hyperType == HypervisorType.VMware) {
return ImageFormat.OVA;
} else if (hyperType == HypervisorType.Ovm) {
return ImageFormat.RAW;
} else if (hyperType == HypervisorType.Hyperv) {
return ImageFormat.VHDX;
} else {
return null;
}
Comment on lines +1114 to +1127
}
Comment thread
sathvikaragi marked this conversation as resolved.

@Override
Expand Down
Loading