From 13a3e8f324229f9f87411a6ad9c1ca7553ce5ec6 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sat, 7 Nov 2015 12:17:53 -0700 Subject: [PATCH 1/2] Tentative fix for "WinError 64 The specified network name is no longer available" issues. --- gns3server/modules/dynamips/dynamips_hypervisor.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gns3server/modules/dynamips/dynamips_hypervisor.py b/gns3server/modules/dynamips/dynamips_hypervisor.py index 6943c862..78726f00 100644 --- a/gns3server/modules/dynamips/dynamips_hypervisor.py +++ b/gns3server/modules/dynamips/dynamips_hypervisor.py @@ -267,8 +267,8 @@ class DynamipsHypervisor: self._writer.write(command.encode()) yield from self._writer.drain() except OSError as e: - raise DynamipsError("Lost communication with {host}:{port} :{error}, Dynamips process running: {run}" - .format(host=self._host, port=self._port, error=e, run=self.is_running())) + raise DynamipsError("Could not send Dynamips command '{command}' to {host}:{port}: {error}, process running: {run}" + .format(command=command, host=self._host, port=self._port, error=e, run=self.is_running())) # Now retrieve the result data = [] @@ -282,13 +282,19 @@ class DynamipsHypervisor: # task has been canceled but continue to read # any remaining data sent by the hypervisor continue + except ConnectionResetError as e: + # Sometimes WinError 64 (ERROR_NETNAME_DELETED) is returned here on Windows. + # These happen if connection reset is received before IOCP could complete + # a previous operation. Ignore and try again.... + log.warning("Connection reset received while reading Dynamips response: {}".format(e)) + continue if not chunk: raise DynamipsError("No data returned from {host}:{port}, Dynamips process running: {run}" .format(host=self._host, port=self._port, run=self.is_running())) buf += chunk.decode("utf-8", errors="ignore") except OSError as e: - raise DynamipsError("Lost communication with {host}:{port} :{error}, Dynamips process running: {run}" - .format(host=self._host, port=self._port, error=e, run=self.is_running())) + raise DynamipsError("Could not read response for '{command}' from {host}:{port}: {error}, process running: {run}" + .format(command=command, host=self._host, port=self._port, error=e, run=self.is_running())) # If the buffer doesn't end in '\n' then we can't be done try: From 9ca72f3bbcbd490c368aa5a45c28438adc49eca9 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sun, 8 Nov 2015 12:01:25 -0700 Subject: [PATCH 2/2] Correctly display log messages. --- gns3server/modules/dynamips/dynamips_hypervisor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gns3server/modules/dynamips/dynamips_hypervisor.py b/gns3server/modules/dynamips/dynamips_hypervisor.py index 78726f00..cc01cf8d 100644 --- a/gns3server/modules/dynamips/dynamips_hypervisor.py +++ b/gns3server/modules/dynamips/dynamips_hypervisor.py @@ -268,7 +268,7 @@ class DynamipsHypervisor: yield from self._writer.drain() except OSError as e: raise DynamipsError("Could not send Dynamips command '{command}' to {host}:{port}: {error}, process running: {run}" - .format(command=command, host=self._host, port=self._port, error=e, run=self.is_running())) + .format(command=command.strip(), host=self._host, port=self._port, error=e, run=self.is_running())) # Now retrieve the result data = [] @@ -294,7 +294,7 @@ class DynamipsHypervisor: buf += chunk.decode("utf-8", errors="ignore") except OSError as e: raise DynamipsError("Could not read response for '{command}' from {host}:{port}: {error}, process running: {run}" - .format(command=command, host=self._host, port=self._port, error=e, run=self.is_running())) + .format(command=command.strip(), host=self._host, port=self._port, error=e, run=self.is_running())) # If the buffer doesn't end in '\n' then we can't be done try: