diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index bc319b95064..df5e205dbd6 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -1387,6 +1387,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) { @@ -1395,11 +1400,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);