@@ -3933,7 +3933,7 @@ private UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOffe
39333933 rootDiskOfferingId = diskOfferingId ;
39343934 diskOfferingId = null ;
39353935 }
3936- if (!customParameters .containsKey (VmDetailConstants .ROOT_DISK_SIZE )) {
3936+ if (!customParameters .containsKey (VmDetailConstants .ROOT_DISK_SIZE ) && diskSize != null ) {
39373937 customParameters .put (VmDetailConstants .ROOT_DISK_SIZE , String .valueOf (diskSize ));
39383938 }
39393939 }
@@ -4320,7 +4320,14 @@ public boolean checkIfDynamicScalingCanBeEnabled(VirtualMachine vm, ServiceOffer
43204320 */
43214321 protected long configureCustomRootDiskSize (Map <String , String > customParameters , VMTemplateVO template , HypervisorType hypervisorType , DiskOfferingVO rootDiskOffering ) {
43224322 verifyIfHypervisorSupportsRootdiskSizeOverride (hypervisorType );
4323- long rootDiskSizeInBytes = verifyAndGetDiskSize (rootDiskOffering , NumbersUtil .parseLong (customParameters .get (VmDetailConstants .ROOT_DISK_SIZE ), -1 ));
4323+ Long rootDiskSizeCustomParam = null ;
4324+ if (customParameters .containsKey (VmDetailConstants .ROOT_DISK_SIZE )) {
4325+ rootDiskSizeCustomParam = NumbersUtil .parseLong (customParameters .get (VmDetailConstants .ROOT_DISK_SIZE ), -1 );
4326+ if (rootDiskSizeCustomParam <= 0 ) {
4327+ throw new InvalidParameterValueException ("Root disk size should be a positive number." );
4328+ }
4329+ }
4330+ long rootDiskSizeInBytes = verifyAndGetDiskSize (rootDiskOffering , rootDiskSizeCustomParam );
43244331 if (rootDiskSizeInBytes > 0 ) { //if the size at DiskOffering is not zero then the Service Offering had it configured, it holds priority over the User custom size
43254332 _volumeService .validateVolumeSizeInBytes (rootDiskSizeInBytes );
43264333 long rootDiskSizeInGiB = rootDiskSizeInBytes / GiB_TO_BYTES ;
@@ -4329,11 +4336,7 @@ protected long configureCustomRootDiskSize(Map<String, String> customParameters,
43294336 }
43304337
43314338 if (customParameters .containsKey (VmDetailConstants .ROOT_DISK_SIZE )) {
4332- Long rootDiskSize = NumbersUtil .parseLong (customParameters .get (VmDetailConstants .ROOT_DISK_SIZE ), -1 );
4333- if (rootDiskSize <= 0 ) {
4334- throw new InvalidParameterValueException ("Root disk size should be a positive number." );
4335- }
4336- rootDiskSize *= GiB_TO_BYTES ;
4339+ Long rootDiskSize = rootDiskSizeCustomParam * GiB_TO_BYTES ;
43374340 _volumeService .validateVolumeSizeInBytes (rootDiskSize );
43384341 return rootDiskSize ;
43394342 } else {
0 commit comments