Pearl1594 commented on a change in pull request #4859:
URL: https://github.com/apache/cloudstack/pull/4859#discussion_r617241288



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -2966,9 +2966,20 @@ public UserVm destroyVm(DestroyVMCmd cmd) throws 
ResourceUnavailableException, C
         checkForUnattachedVolumes(vmId, volumesToBeDeleted);
         validateVolumes(volumesToBeDeleted);
 
+        List<VolumeVO> allVolumes = null;
+        if (vm.getHypervisorType() == HypervisorType.VMware) {
+            allVolumes = _volsDao.findByInstance(vm.getId());
+            allVolumes.removeIf(vol -> vol.getVolumeType() == 
Volume.Type.ROOT);
+        }else {
+            allVolumes = volumesToBeDeleted;
+        }
+        for (VolumeVO volume : allVolumes) {
+             _accountMgr.checkAccess(ctx.getCallingAccount(), null, true, 
volume);
+        }
+

Review comment:
       We could probably use the following to check access for all volumes to 
be deleted?
   ```suggestion
          final ControlledEntity[] volumesToDelete = 
volumesToBeDeleted.toArray(new ControlledEntity[0]);
           _accountMgr.checkAccess(ctx.getCallingAccount(), null, true, 
volumesToDelete);
   
   ```

##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -2966,9 +2966,20 @@ public UserVm destroyVm(DestroyVMCmd cmd) throws 
ResourceUnavailableException, C
         checkForUnattachedVolumes(vmId, volumesToBeDeleted);
         validateVolumes(volumesToBeDeleted);
 
+        List<VolumeVO> allVolumes = null;
+        if (vm.getHypervisorType() == HypervisorType.VMware) {
+            allVolumes = _volsDao.findByInstance(vm.getId());
+            allVolumes.removeIf(vol -> vol.getVolumeType() == 
Volume.Type.ROOT);
+        }else {
+            allVolumes = volumesToBeDeleted;
+        }

Review comment:
       @lujiefsi I believe this section isn't required as it causes issues wrt 
recovery of destroyed VMs with their data disks on VMWare 
(https://github.com/apache/cloudstack/pull/4493/files#diff-865f710fe60b9b62ff8c2cbce8a8342e4f6fca658223119762285fd5f7857f08L2949).
 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to