1
0
mirror of https://github.com/GNS3/gns3-server synced 2025-07-16 11:38:26 +00:00

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

View File

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