Lock qemu vm during start / stop operations

Fix #301
This commit is contained in:
Julien Duponchelle 2015-08-27 16:06:11 +02:00
parent 699647dbda
commit c361d27531
2 changed files with 65 additions and 60 deletions

View File

@ -71,6 +71,7 @@ class QemuVM(BaseVM):
self._cpulimit_process = None
self._monitor = None
self._stdout_file = ""
self._execute_lock = asyncio.Lock()
# QEMU VM settings
if qemu_path:
@ -818,6 +819,7 @@ class QemuVM(BaseVM):
Starts this QEMU VM.
"""
with (yield from self._execute_lock):
if self.is_running():
# resume the VM if it is paused
yield from self.resume()
@ -888,6 +890,7 @@ class QemuVM(BaseVM):
Stops this QEMU VM.
"""
with (yield from self._execute_lock):
# stop the QEMU process
self._hw_virtualization = False
if self.is_running():

View File

@ -104,6 +104,8 @@ class Route(object):
if request.headers["AUTHORIZATION"] == aiohttp.helpers.BasicAuth(user, password).encode():
return
log.error("Invalid auth. Username should %s", user)
response = Response(request=request, route=route)
response.set_status(401)
response.headers["WWW-Authenticate"] = 'Basic realm="GNS3 server"'