server: Limit API from trying to start a VM that is already running (#3979)

Fixes #2736
This commit is contained in:
Chief 2020-07-07 10:18:02 +03:00 committed by GitHub
parent e8fe35bd59
commit 7a41e27526
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -4632,6 +4632,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
throw new InvalidParameterValueException("unable to find a virtual machine with id " + vmId);
}
if (vm.getState()== State.Running) {
throw new InvalidParameterValueException("The virtual machine "+ vm.getUuid()+ " ("+ vm.getDisplayName()+ ") is already running");
}
_accountMgr.checkAccess(callerAccount, null, true, vm);
Account owner = _accountDao.findById(vm.getAccountId());