diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index c856379b812..69558250da3 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -1382,6 +1382,11 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic volume = _volsDao.findByInstanceAndDeviceId(cmmd.getVirtualMachineId(), cmmd.getDeviceId()).get(0); } + // Check that the volume ID is valid + if (volume == null) { + throw new InvalidParameterValueException("Unable to find volume with ID: " + volumeId); + } + Long vmId = null; if (cmmd.getVirtualMachineId() == null) { @@ -1390,11 +1395,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic vmId = cmmd.getVirtualMachineId(); } - // Check that the volume ID is valid - if (volume == null) { - throw new InvalidParameterValueException("Unable to find volume with ID: " + volumeId); - } - // Permissions check _accountMgr.checkAccess(caller, null, true, volume);