From af9c6b7bdcab5c0613f82931ca403f8d293781cd Mon Sep 17 00:00:00 2001 From: Sudharma Jain Date: Tue, 28 Mar 2017 17:57:28 +0530 Subject: [PATCH] CLOUDSTACK-9851 travis CI build failure after merge of PR#1953 (cherry picked from commit 7348f9412a20ecff2f7a9f26633013e06e5394dd) Signed-off-by: Rohit Yadav --- server/src/com/cloud/storage/VolumeApiServiceImpl.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 87b003d6bbe..fcdc660b48e 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -1437,7 +1437,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic // that supported by hypervisor if (deviceId == null || deviceId.longValue() != 0) { List existingDataVolumes = _volsDao.findByInstanceAndType(vmId, Volume.Type.DATADISK); - int maxAttachableDataVolumesSupported = getMaxDataVolumesSupported(vm) - 2; //IDs: 0 (ROOT) and 3 (CD-ROM) are reserved + int maxAttachableDataVolumesSupported = getMaxDataVolumesSupported(vm); if (existingDataVolumes.size() >= maxAttachableDataVolumesSupported) { throw new InvalidParameterValueException("The specified VM already has the maximum number of data disks (" + maxAttachableDataVolumesSupported + ") attached. Please specify another VM."); } @@ -2569,11 +2569,12 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic private Long getDeviceId(UserVmVO vm, Long deviceId) { // allocate deviceId - int maxDeviceId = getMaxDataVolumesSupported(vm) - 1; + int maxDevices = getMaxDataVolumesSupported(vm) + 2; // add 2 to consider devices root volume and cdrom + int maxDeviceId = maxDevices - 1; List vols = _volsDao.findByInstance(vm.getId()); if (deviceId != null) { - if (deviceId.longValue() <= 0 || deviceId.longValue() > maxDeviceId || deviceId.longValue() == 3) { - throw new RuntimeException("deviceId should be 1,2,4-" + maxDeviceId); + if (deviceId.longValue() < 0 || deviceId.longValue() > maxDeviceId || deviceId.longValue() == 3) { + throw new RuntimeException("deviceId should be 0,1,2,4-" + maxDeviceId); } for (VolumeVO vol : vols) { if (vol.getDeviceId().equals(deviceId)) {