bug 8525: we can't create template from snapshots belonging to one volume at the same time

status 8525: resolved fixed
This commit is contained in:
anthony 2011-02-16 15:23:41 -08:00
parent eb7d531456
commit 893f8b5f73
1 changed files with 6 additions and 0 deletions

View File

@ -1414,9 +1414,15 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
// This can be sent to a KVM host too.
StoragePool pool = _storagePoolDao.findById(volume.getPoolId());
CreatePrivateTemplateAnswer answer = null;
volume = _volsDao.acquireInLockTable(volumeId, 10);
if( volume == null ) {
throw new CloudRuntimeException("Creating template failed due to volume:" + volumeId + " is being used, try it later ");
}
try {
answer = (CreatePrivateTemplateAnswer)_storageMgr.sendToPool(pool, cmd);
} catch (StorageUnavailableException e) {
} finally {
_volsDao.releaseFromLockTable(volumeId);
}
if ((answer != null) && answer.getResult()) {