1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

Fix when qemu exit by itself clean other processes

Fix https://github.com/GNS3/gns3-gui/issues/1898
This commit is contained in:
Julien Duponchelle 2017-03-03 18:40:26 +01:00
parent e828c9068a
commit 5e7f97b175
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
3 changed files with 6 additions and 7 deletions

View File

@ -533,7 +533,7 @@ class BaseNode:
server_config = self._manager.config.get_section_config("Server") server_config = self._manager.config.get_section_config("Server")
server_host = server_config.get("host") server_host = server_config.get("host")
if not self._ubridge_hypervisor: if not self.ubridge:
self._ubridge_hypervisor = Hypervisor(self._project, self.ubridge_path, self.working_dir, server_host) self._ubridge_hypervisor = Hypervisor(self._project, self.ubridge_path, self.working_dir, server_host)
log.info("Starting new uBridge hypervisor {}:{}".format(self._ubridge_hypervisor.host, self._ubridge_hypervisor.port)) log.info("Starting new uBridge hypervisor {}:{}".format(self._ubridge_hypervisor.host, self._ubridge_hypervisor.port))
yield from self._ubridge_hypervisor.start() yield from self._ubridge_hypervisor.start()

View File

@ -934,6 +934,7 @@ class QemuVM(BaseNode):
except OSError as e: except OSError as e:
raise QemuError("Could not start QEMU console {}\n".format(e)) raise QemuError("Could not start QEMU console {}\n".format(e))
@asyncio.coroutine
def _termination_callback(self, returncode): def _termination_callback(self, returncode):
""" """
Called when the process has stopped. Called when the process has stopped.
@ -943,9 +944,7 @@ class QemuVM(BaseNode):
if self.started: if self.started:
log.info("QEMU process has stopped, return code: %d", returncode) log.info("QEMU process has stopped, return code: %d", returncode)
self.status = "stopped" yield from self.stop()
self._hw_virtualization = False
self._process = None
# A return code of 1 seem fine on Windows # A return code of 1 seem fine on Windows
if returncode != 0 and (returncode != 1 or not sys.platform.startswith("win")): if returncode != 0 and (returncode != 1 or not sys.platform.startswith("win")):
self.project.emit("log.error", {"message": "QEMU process has stopped, return code: {}\n{}".format(returncode, self.read_stdout())}) self.project.emit("log.error", {"message": "QEMU process has stopped, return code: {}\n{}".format(returncode, self.read_stdout())})

View File

@ -144,7 +144,7 @@ def test_termination_callback(vm, async_run):
vm.status = "started" vm.status = "started"
with NotificationManager.instance().queue() as queue: with NotificationManager.instance().queue() as queue:
vm._termination_callback(0) async_run(vm._termination_callback(0))
assert vm.status == "stopped" assert vm.status == "stopped"
async_run(queue.get(0)) #  Ping async_run(queue.get(0)) #  Ping
@ -163,10 +163,10 @@ def test_termination_callback_error(vm, tmpdir, async_run):
vm._stdout_file = str(tmpdir / "qemu.log") vm._stdout_file = str(tmpdir / "qemu.log")
with NotificationManager.instance().queue() as queue: with NotificationManager.instance().queue() as queue:
vm._termination_callback(1) async_run(vm._termination_callback(1))
assert vm.status == "stopped" assert vm.status == "stopped"
async_run(queue.get(0)) #  Ping async_run(queue.get(0)) # Ping
(action, event, kwargs) = queue.get_nowait() (action, event, kwargs) = queue.get_nowait()
assert action == "node.updated" assert action == "node.updated"