Skip to content

Commit 65c7070

Browse files
committed
Merge remote-tracking branch 'apache/4.17' into main
2 parents c581181 + c290cbc commit 65c7070

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,13 +2053,25 @@ private void changeDiskOfferingForRootVolume(Long vmId, DiskOfferingVO newDiskOf
20532053

20542054
for (final VolumeVO rootVolumeOfVm : vols) {
20552055
DiskOfferingVO currentRootDiskOffering = _diskOfferingDao.findById(rootVolumeOfVm.getDiskOfferingId());
2056+
Long rootDiskSize= null;
2057+
Long rootDiskSizeBytes = null;
2058+
if (customParameters.containsKey(ApiConstants.ROOT_DISK_SIZE)) {
2059+
rootDiskSize = Long.parseLong(customParameters.get(ApiConstants.ROOT_DISK_SIZE));
2060+
rootDiskSizeBytes = rootDiskSize << 30;
2061+
}
2062+
if (currentRootDiskOffering.getId() == newDiskOffering.getId() &&
2063+
(!newDiskOffering.isCustomized() || (newDiskOffering.isCustomized() && Objects.equals(rootVolumeOfVm.getSize(), rootDiskSizeBytes)))) {
2064+
if (s_logger.isDebugEnabled()) {
2065+
s_logger.debug(String.format("Volume %s is already having disk offering %s", rootVolumeOfVm, newDiskOffering.getUuid()));
2066+
}
2067+
continue;
2068+
}
20562069
HypervisorType hypervisorType = _volsDao.getHypervisorType(rootVolumeOfVm.getId());
20572070
if (HypervisorType.Simulator != hypervisorType) {
20582071
Long minIopsInNewDiskOffering = null;
20592072
Long maxIopsInNewDiskOffering = null;
20602073
boolean autoMigrate = false;
20612074
boolean shrinkOk = false;
2062-
Long rootDiskSize = null;
20632075
if (customParameters.containsKey(ApiConstants.MIN_IOPS)) {
20642076
minIopsInNewDiskOffering = Long.parseLong(customParameters.get(ApiConstants.MIN_IOPS));
20652077
}
@@ -2072,9 +2084,6 @@ private void changeDiskOfferingForRootVolume(Long vmId, DiskOfferingVO newDiskOf
20722084
if (customParameters.containsKey(ApiConstants.SHRINK_OK)) {
20732085
shrinkOk = Boolean.parseBoolean(customParameters.get(ApiConstants.SHRINK_OK));
20742086
}
2075-
if (customParameters.containsKey(ApiConstants.ROOT_DISK_SIZE)) {
2076-
rootDiskSize = Long.parseLong(customParameters.get(ApiConstants.ROOT_DISK_SIZE));
2077-
}
20782087
ChangeOfferingForVolumeCmd changeOfferingForVolumeCmd = new ChangeOfferingForVolumeCmd(rootVolumeOfVm.getId(), newDiskOffering.getId(), minIopsInNewDiskOffering, maxIopsInNewDiskOffering, autoMigrate, shrinkOk);
20792088
if (rootDiskSize != null) {
20802089
changeOfferingForVolumeCmd.setSize(rootDiskSize);

0 commit comments

Comments
 (0)