From aa83fcc7d173b78b4f5ed5b3abfce663c6fbc422 Mon Sep 17 00:00:00 2001 From: grossmj Date: Fri, 20 Mar 2020 21:30:05 +1030 Subject: [PATCH] Monitor ubrige processes. --- gns3server/ubridge/hypervisor.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gns3server/ubridge/hypervisor.py b/gns3server/ubridge/hypervisor.py index 5d0d0582..7de8d1d7 100644 --- a/gns3server/ubridge/hypervisor.py +++ b/gns3server/ubridge/hypervisor.py @@ -28,6 +28,7 @@ import re from gns3server.utils import parse_version from gns3server.utils.asyncio import wait_for_process_termination +from gns3server.utils.asyncio import monitor_process from gns3server.utils.asyncio import subprocess_check_output from .ubridge_hypervisor import UBridgeHypervisor from .ubridge_error import UbridgeError @@ -176,6 +177,7 @@ class Hypervisor(UBridgeHypervisor): env=env) log.info("ubridge started PID={}".format(self._process.pid)) + monitor_process(self._process, self._termination_callback) except (OSError, subprocess.SubprocessError) as e: ubridge_stdout = self.read_stdout() log.error("Could not start ubridge: {}\n{}".format(e, ubridge_stdout)) @@ -188,9 +190,12 @@ class Hypervisor(UBridgeHypervisor): :param returncode: Process returncode """ - log.info("uBridge process has stopped, return code: %d", returncode) if returncode != 0: - self._project.emit("log.error", {"message": "uBridge process has stopped, return code: {}\n{}".format(returncode, self.read_stdout())}) + error_msg = "uBridge process has stopped, return code: {}\n{}\n".format(returncode, self.read_stdout()) + log.error(error_msg) + self._project.emit("log.error", {"message": error_msg}) + else: + log.info("uBridge process has stopped, return code: %d", returncode) async def stop(self): """