Repository: cloudstack Updated Branches: refs/heads/master 7ef122dcc -> e5ffcab09
Moving the call to getDeviceId(long, long) avoids a race condition when two volumes are being attached to a VM at the same time Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e5ffcab0 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e5ffcab0 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e5ffcab0 Branch: refs/heads/master Commit: e5ffcab09dd4f70d2755f5378185862a387a4621 Parents: 7ef122d Author: Mike Tutkowski <[email protected]> Authored: Sat Jan 24 00:06:37 2015 -0700 Committer: Mike Tutkowski <[email protected]> Committed: Sat Jan 24 00:36:07 2015 -0700 ---------------------------------------------------------------------- server/src/com/cloud/storage/VolumeApiServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e5ffcab0/server/src/com/cloud/storage/VolumeApiServiceImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 0abb629..22c801f 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -1303,7 +1303,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic throw new InvalidParameterValueException("The specified VM already has the maximum number of data disks (" + maxDataVolumesSupported + "). Please specify another VM."); } } - deviceId = getDeviceId(vmId, deviceId); // If local storage is disabled then attaching a volume with local disk // offering not allowed @@ -2300,6 +2299,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic } DataTO volTO = volFactory.getVolume(volumeToAttach.getId()).getTO(); + + deviceId = getDeviceId(vm.getId(), deviceId); + DiskTO disk = new DiskTO(volTO, deviceId, volumeToAttach.getPath(), volumeToAttach.getVolumeType()); AttachCommand cmd = new AttachCommand(disk, vm.getInstanceName());
