3333import org .zstack .header .exception .CloudRuntimeException ;
3434import org .zstack .header .host .*;
3535import org .zstack .header .image .ImageBackupStorageRefInventory ;
36+ import org .zstack .header .image .ImageConstant ;
3637import org .zstack .header .image .ImageConstant .ImageMediaType ;
3738import org .zstack .header .image .ImageInventory ;
3839import org .zstack .header .image .ImageStatus ;
@@ -202,6 +203,7 @@ public static class CreateEmptyVolumeCmd extends AgentCommand {
202203 private String name ;
203204 private String volumeUuid ;
204205 private String backingFile ;
206+ private String format ;
205207
206208 public String getBackingFile () {
207209 return backingFile ;
@@ -211,6 +213,14 @@ public void setBackingFile(String backingFile) {
211213 this .backingFile = backingFile ;
212214 }
213215
216+ public String getFormat () {
217+ return format ;
218+ }
219+
220+ public void setFormat (String format ) {
221+ this .format = format ;
222+ }
223+
214224 public String getInstallUrl () {
215225 return installUrl ;
216226 }
@@ -1258,7 +1268,7 @@ public void success(VolumeStats returnValue) {
12581268 VolumeInventory vol = msg .getVolume ();
12591269 vol .setInstallPath (returnValue .getInstallPath ());
12601270 vol .setActualSize (returnValue .getActualSize ());
1261- vol .setFormat (VolumeConstant . VOLUME_FORMAT_QCOW2 );
1271+ vol .setFormat (returnValue . getFormat () );
12621272 if (returnValue .getSize () != null ) {
12631273 vol .setSize (returnValue .getSize ());
12641274 }
@@ -1283,7 +1293,9 @@ public void createEmptyVolumeWithBackingFile(final VolumeInventory volume, final
12831293 cmd .setAccountUuid (acntMgr .getOwnerAccountUuidOfResource (volume .getUuid ()));
12841294 if (volume .getInstallPath () != null && !volume .getInstallPath ().equals ("" )) {
12851295 cmd .setInstallUrl (volume .getInstallPath ());
1296+ cmd .setFormat (ImageConstant .QCOW2_FORMAT_STRING );
12861297 } else {
1298+ cmd .setFormat (ImageConstant .QCOW2_FORMAT_STRING );
12871299 if (VolumeType .Root .toString ().equals (volume .getType ())) {
12881300 cmd .setInstallUrl (makeRootVolumeInstallUrl (volume ));
12891301 } else if (VolumeType .Data .toString ().equals (volume .getType ())) {
@@ -1294,6 +1306,7 @@ public void createEmptyVolumeWithBackingFile(final VolumeInventory volume, final
12941306 cmd .setInstallUrl (makeDataVolumeInstallUrl (volume .getUuid ()));
12951307 } else if (VolumeType .NVRAM .toString ().equals (volume .getType ())) {
12961308 cmd .setInstallUrl (makeNvRamVolumeInstallUrl (volume .getUuid ()));
1309+ cmd .setFormat (ImageConstant .RAW_FORMAT_STRING );
12971310 }
12981311 }
12991312 cmd .setName (volume .getName ());
@@ -1304,7 +1317,9 @@ public void createEmptyVolumeWithBackingFile(final VolumeInventory volume, final
13041317 httpCall (CREATE_EMPTY_VOLUME_PATH , hostUuid , cmd , CreateEmptyVolumeRsp .class , new ReturnValueCompletion <CreateEmptyVolumeRsp >(completion ) {
13051318 @ Override
13061319 public void success (CreateEmptyVolumeRsp returnValue ) {
1307- completion .success (new VolumeStats (cmd .getInstallUrl (), returnValue .actualSize , returnValue .size ));
1320+ final VolumeStats stats = new VolumeStats (cmd .getInstallUrl (), returnValue .actualSize , returnValue .size );
1321+ stats .setFormat (cmd .getFormat ());
1322+ completion .success (stats );
13081323 }
13091324
13101325 @ Override
0 commit comments