mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-10-22 02:42:22 +03:00
fix(qemu): build a command line for a headless node
_console_options() fell through the "none" branch and returned None, so _build_command() blew up on `command.extend(None)`: a QEMU node with console_type "none" -- offered by the GUI, and what API/MCP-driven labs use to skip the console entirely -- failed to start with a 500 and a traceback. Return an empty list, exactly like _aux_options() already does, and cover it with a test that builds the command line for a headless node. Verified on a live instance: such a node now starts (204) with `console: null` and no -serial device in the QEMU command line.
This commit is contained in:
parent
187201a08c
commit
a1fcd29bce
@ -2042,6 +2042,7 @@ class QemuVM(KernelDatapathMixin, BaseNode):
|
|||||||
return self._spice_with_agent_options(self.console)
|
return self._spice_with_agent_options(self.console)
|
||||||
elif self._console_type != "none":
|
elif self._console_type != "none":
|
||||||
raise QemuError(f"Console type {self._console_type} is unknown")
|
raise QemuError(f"Console type {self._console_type} is unknown")
|
||||||
|
return []
|
||||||
|
|
||||||
def _aux_options(self):
|
def _aux_options(self):
|
||||||
|
|
||||||
|
|||||||
@ -624,6 +624,22 @@ async def test_build_command(vm, fake_qemu_binary):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_build_command_console_none(vm):
|
||||||
|
"""
|
||||||
|
A headless QEMU node (console_type none) builds a command line without a
|
||||||
|
serial device: the console options for "none" used to fall through and
|
||||||
|
return None, which made node start fail with a TypeError.
|
||||||
|
"""
|
||||||
|
|
||||||
|
vm.console_type = "none"
|
||||||
|
os.environ["DISPLAY"] = "0:0"
|
||||||
|
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()):
|
||||||
|
cmd = await vm._build_command()
|
||||||
|
assert "-serial" not in cmd
|
||||||
|
assert "-netdev" in cmd
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_build_command_manual_uuid(vm):
|
async def test_build_command_manual_uuid(vm):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user