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

Catch exception when a process cannot be killed. Fixes #296.

This commit is contained in:
grossmj 2015-09-03 16:18:27 -06:00
parent eb5f9c48f2
commit fda33c56de
3 changed files with 14 additions and 5 deletions

View File

@ -140,7 +140,12 @@ class Hypervisor(DynamipsHypervisor):
except asyncio.TimeoutError: except asyncio.TimeoutError:
if self._process.returncode is None: if self._process.returncode is None:
log.warn("Dynamips process {} is still running... killing it".format(self._process.pid)) log.warn("Dynamips process {} is still running... killing it".format(self._process.pid))
self._process.kill() try:
self._process.kill()
except OSError as e:
log.error("Cannot stop the Dynamips process: {}".format(e))
if self._process.returncode is None:
log.warn('Dynamips hypervisor with PID={} is still running'.format(self._process.pid))
if self._stdout_file and os.access(self._stdout_file, os.W_OK): if self._stdout_file and os.access(self._stdout_file, os.W_OK):
try: try:

View File

@ -604,9 +604,12 @@ class QemuVM(BaseVM):
self._process.terminate() self._process.terminate()
self._process.wait() self._process.wait()
except subprocess.TimeoutExpired: except subprocess.TimeoutExpired:
self._process.kill() try:
self._process.kill()
except OSError as e:
log.error("Cannot stop the Qemu process: {}".format(e))
if self._process.returncode is None: if self._process.returncode is None:
log.warn('QEMU VM "{}" PID={} is still running'.format(self._name, self._process.pid)) log.warn('QEMU VM "{}" with PID={} is still running'.format(self._name, self._process.pid))
self._process = None self._process = None
self._started = False self._started = False
self._stop_cpulimit() self._stop_cpulimit()

View File

@ -253,11 +253,12 @@ class VPCSVM(BaseVM):
yield from gns3server.utils.asyncio.wait_for_process_termination(self._process, timeout=3) yield from gns3server.utils.asyncio.wait_for_process_termination(self._process, timeout=3)
except asyncio.TimeoutError: except asyncio.TimeoutError:
if self._process.returncode is None: if self._process.returncode is None:
log.warn("VPCS process {} is still running... killing it".format(self._process.pid))
try: try:
self._process.kill() self._process.kill()
except OSError as e: except OSError as e:
raise VPCSError("Can not stop the VPCS process: {}".format(e)) log.error("Cannot stop the VPCS process: {}".format(e))
if self._process.returncode is None:
log.warn('VPCS VM "{}" with PID={} is still running'.format(self._name, self._process.pid))
self._process = None self._process = None
self._started = False self._started = False