From 56965433593efa963cb4f6137ae8be1af65623e7 Mon Sep 17 00:00:00 2001 From: Edison Su Date: Fri, 19 Aug 2011 14:26:47 -0700 Subject: [PATCH] disable attach volume to a vm if volume state is not in allocated or ready state --- server/src/com/cloud/vm/UserVmManagerImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 9a48add3c31..f36f70d5c22 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -486,9 +486,13 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager } // Check that the volume is stored on shared storage - if (!Volume.State.Allocated.equals(volume.getState()) && !_storageMgr.volumeOnSharedStoragePool(volume)) { + if (!_storageMgr.volumeOnSharedStoragePool(volume)) { throw new InvalidParameterValueException("Please specify a volume that has been created on a shared storage pool."); } + + if (!(Volume.State.Allocated.equals(volume.getState()) || Volume.State.Ready.equals(volume.getState()))) { + throw new InvalidParameterValueException("Volume state must be in Allocated or Ready state"); + } // Check that the volume is not currently attached to any VM if (volume.getInstanceId() != null) {