mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 09:18:08 +00:00
Merge pull request #2387 from GNS3/bugfix/3588
Fix check to test if IPv6 is enabled on host
This commit is contained in:
commit
a58fb320ac
@ -47,7 +47,7 @@ from ..base_node import BaseNode
|
|||||||
from ...schemas.qemu import QEMU_OBJECT_SCHEMA, QEMU_PLATFORMS
|
from ...schemas.qemu import QEMU_OBJECT_SCHEMA, QEMU_PLATFORMS
|
||||||
from ...utils.asyncio import monitor_process
|
from ...utils.asyncio import monitor_process
|
||||||
from ...utils.images import md5sum
|
from ...utils.images import md5sum
|
||||||
from ...utils import macaddress_to_int, int_to_macaddress
|
from ...utils import macaddress_to_int, int_to_macaddress, is_ipv6_enabled
|
||||||
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@ -1672,13 +1672,14 @@ class QemuVM(BaseNode):
|
|||||||
if self._console:
|
if self._console:
|
||||||
console_host = self._manager.port_manager.console_host
|
console_host = self._manager.port_manager.console_host
|
||||||
if console_host == "0.0.0.0":
|
if console_host == "0.0.0.0":
|
||||||
if socket.has_ipv6:
|
try:
|
||||||
# to fix an issue with Qemu when IPv4 is not enabled
|
if is_ipv6_enabled():
|
||||||
# see https://github.com/GNS3/gns3-gui/issues/2352
|
# to fix an issue with Qemu when IPv4 is not enabled
|
||||||
# FIXME: consider making this more global (not just for Qemu + SPICE)
|
# see https://github.com/GNS3/gns3-gui/issues/2352
|
||||||
console_host = "::"
|
# FIXME: consider making this more global (not just for Qemu + SPICE)
|
||||||
else:
|
console_host = "::"
|
||||||
raise QemuError("IPv6 must be enabled in order to use the SPICE console")
|
except OSError as e:
|
||||||
|
raise QemuError("Could not check if IPv6 is enabled: {}".format(e))
|
||||||
return ["-spice",
|
return ["-spice",
|
||||||
"addr={},port={},disable-ticketing".format(console_host, self._console),
|
"addr={},port={},disable-ticketing".format(console_host, self._console),
|
||||||
"-vga", "qxl"]
|
"-vga", "qxl"]
|
||||||
|
@ -21,6 +21,8 @@ import re
|
|||||||
import shlex
|
import shlex
|
||||||
import textwrap
|
import textwrap
|
||||||
import posixpath
|
import posixpath
|
||||||
|
import socket
|
||||||
|
import errno
|
||||||
|
|
||||||
|
|
||||||
def force_unix_path(path):
|
def force_unix_path(path):
|
||||||
@ -100,3 +102,21 @@ def shlex_quote(s):
|
|||||||
return s if re.match(r'^[-_\w./]+$', s) else '"%s"' % s.replace('"', '\\"')
|
return s if re.match(r'^[-_\w./]+$', s) else '"%s"' % s.replace('"', '\\"')
|
||||||
else:
|
else:
|
||||||
return shlex.quote(s)
|
return shlex.quote(s)
|
||||||
|
|
||||||
|
|
||||||
|
def is_ipv6_enabled() -> bool:
|
||||||
|
|
||||||
|
if not socket.has_ipv6:
|
||||||
|
return False # the socket library has no support for IPv6
|
||||||
|
try:
|
||||||
|
with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as sock:
|
||||||
|
sock.bind(("::1", 0))
|
||||||
|
return True
|
||||||
|
except OSError as e:
|
||||||
|
if e.errno in (errno.EADDRNOTAVAIL, errno.EAFNOSUPPORT):
|
||||||
|
# EADDRNOTAVAIL is the errno if IPv6 modules/drivers are loaded but disabled.
|
||||||
|
# EAFNOSUPPORT is the errno if IPv6 modules/drivers are not loaded at all.
|
||||||
|
return False
|
||||||
|
if e.errno == errno.EADDRINUSE:
|
||||||
|
return True
|
||||||
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user