This is an automated email from the ASF dual-hosted git repository. rohit pushed a commit to branch 4.14 in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.14 by this push: new 6b1c94e server: fix root disk size on vm reset (#4638) 6b1c94e is described below commit 6b1c94ea3e4cd19aeca88908e919b229b3f917d6 Author: Abhishek Kumar <abhishek.mr...@gmail.com> AuthorDate: Sat Apr 10 13:31:51 2021 +0530 server: fix root disk size on vm reset (#4638) If VM details contain rootdisksize, volume entry in DB should reflect correct size when VM reset is performed. Fixes #3957 Signed-off-by: Abhishek Kumar <abhishek.mr...@gmail.com> Co-authored-by: Pearl Dsilva <pearl.dsi...@shapeblue.com> --- server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java | 8 ++++++-- server/src/main/java/com/cloud/vm/UserVmManagerImpl.java | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java index 35314e8..f491284 100644 --- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java @@ -175,6 +175,7 @@ import com.cloud.vm.VmWorkResizeVolume; import com.cloud.vm.VmWorkSerializer; import com.cloud.vm.VmWorkTakeVolumeSnapshot; import com.cloud.vm.dao.UserVmDao; +import com.cloud.vm.dao.UserVmDetailsDao; import com.cloud.vm.dao.VMInstanceDao; import com.cloud.vm.snapshot.VMSnapshotVO; import com.cloud.vm.snapshot.dao.VMSnapshotDao; @@ -214,6 +215,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic @Inject private UserVmDao _userVmDao; @Inject + private UserVmDetailsDao userVmDetailsDao; + @Inject private UserVmService _userVmService; @Inject private VolumeDataStoreDao _volumeStoreDao; @@ -901,9 +904,10 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic HypervisorType hypervisorType = _volsDao.getHypervisorType(volume.getId()); - if (hypervisorType != HypervisorType.KVM && hypervisorType != HypervisorType.XenServer && hypervisorType != HypervisorType.VMware && hypervisorType != HypervisorType.Any + if (hypervisorType != HypervisorType.KVM && hypervisorType != HypervisorType.XenServer + && hypervisorType != HypervisorType.VMware && hypervisorType != HypervisorType.Any && hypervisorType != HypervisorType.None) { - throw new InvalidParameterValueException("Hypervisor " + hypervisorType + " does not support rootdisksize override"); + throw new InvalidParameterValueException("Hypervisor " + hypervisorType + " does not support volume resize"); } if (volume.getState() != Volume.State.Ready && volume.getState() != Volume.State.Allocated) { diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java index 684434b..b10a216 100644 --- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java @@ -6714,6 +6714,12 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir newVol = volumeMgr.allocateDuplicateVolume(root, null); } + if (userVmDetailsDao.findDetail(vm.getId(), VmDetailConstants.ROOT_DISK_SIZE) == null && !newVol.getSize().equals(template.getSize())) { + VolumeVO resizedVolume = (VolumeVO) newVol; + resizedVolume.setSize(template.getSize()); + _volsDao.update(resizedVolume.getId(), resizedVolume); + } + // 1. Save usage event and update resource count for user vm volumes _resourceLimitMgr.incrementResourceCount(newVol.getAccountId(), ResourceType.volume, newVol.isDisplay()); _resourceLimitMgr.incrementResourceCount(newVol.getAccountId(), ResourceType.primary_storage, newVol.isDisplay(), new Long(newVol.getSize()));