@@ -1102,19 +1102,29 @@ private VolumeVO createVolumeOnStoragePool(Long volumeId, Long storageId) throws
11021102 VolumeVO volVO = _volsDao .findById (volumeInfo .getId ());
11031103 if (volVO .getFormat () == null ) {
11041104 HypervisorType hyperType = storagePool .getHypervisor ();
1105- volVO .setFormat (getSupportedImageFormatForHypervisor (hyperType ));
1105+ ImageFormat format = getSupportedImageFormatForHypervisor (hyperType );
1106+ if (format != null ) {
1107+ volVO .setFormat (format );
1108+ _volsDao .update (volVO .getId (), volVO );
1109+ }
11061110 }
1107- _volsDao .update (volVO .getId (), volVO );
11081111 return volVO ;
11091112 }
11101113
11111114 private ImageFormat getSupportedImageFormatForHypervisor (HypervisorType hyperType ) {
1112- if (hyperType == HypervisorType .XenServer ) return ImageFormat .VHD ;
1113- if (hyperType == HypervisorType .KVM ) return ImageFormat .QCOW2 ;
1114- if (hyperType == HypervisorType .VMware ) return ImageFormat .OVA ;
1115- if (hyperType == HypervisorType .Ovm ) return ImageFormat .RAW ;
1116- if (hyperType == HypervisorType .Hyperv ) return ImageFormat .VHDX ;
1117- return null ;
1115+ if (hyperType == HypervisorType .XenServer ) {
1116+ return ImageFormat .VHD ;
1117+ } else if (hyperType == HypervisorType .KVM ) {
1118+ return ImageFormat .QCOW2 ;
1119+ } else if (hyperType == HypervisorType .VMware ) {
1120+ return ImageFormat .OVA ;
1121+ } else if (hyperType == HypervisorType .Ovm ) {
1122+ return ImageFormat .RAW ;
1123+ } else if (hyperType == HypervisorType .Hyperv ) {
1124+ return ImageFormat .VHDX ;
1125+ } else {
1126+ return null ;
1127+ }
11181128 }
11191129
11201130 @ Override
0 commit comments