Fix check for IPv6 enabled on host

This commit is contained in:
grossmj
2024-06-17 16:41:40 +02:00
parent 0f3b96f134
commit 39057bd781
2 changed files with 29 additions and 8 deletions

View File

@ -47,7 +47,7 @@ from ..base_node import BaseNode
from ...schemas.qemu import QEMU_OBJECT_SCHEMA, QEMU_PLATFORMS
from ...utils.asyncio import monitor_process
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
@ -1672,13 +1672,14 @@ class QemuVM(BaseNode):
if self._console:
console_host = self._manager.port_manager.console_host
if console_host == "0.0.0.0":
if socket.has_ipv6:
# to fix an issue with Qemu when IPv4 is not enabled
# see https://github.com/GNS3/gns3-gui/issues/2352
# FIXME: consider making this more global (not just for Qemu + SPICE)
console_host = "::"
else:
raise QemuError("IPv6 must be enabled in order to use the SPICE console")
try:
if is_ipv6_enabled():
# to fix an issue with Qemu when IPv4 is not enabled
# see https://github.com/GNS3/gns3-gui/issues/2352
# FIXME: consider making this more global (not just for Qemu + SPICE)
console_host = "::"
except OSError as e:
raise QemuError("Could not check if IPv6 is enabled: {}".format(e))
return ["-spice",
"addr={},port={},disable-ticketing".format(console_host, self._console),
"-vga", "qxl"]