mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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.mrt22@gmail.com> Co-authored-by: Pearl Dsilva <pearl.dsilva@shapeblue.com>
This commit is contained in:
parent
4bab06a74b
commit
6b1c94ea3e
@ -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) {
|
||||
|
||||
@ -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()));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user