diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index e8c73774e..9309e25b5 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -2042,6 +2042,7 @@ class QemuVM(KernelDatapathMixin, BaseNode): return self._spice_with_agent_options(self.console) elif self._console_type != "none": raise QemuError(f"Console type {self._console_type} is unknown") + return [] def _aux_options(self): diff --git a/tests/compute/qemu/test_qemu_vm.py b/tests/compute/qemu/test_qemu_vm.py index 7b39bc4ae..1f4953c27 100644 --- a/tests/compute/qemu/test_qemu_vm.py +++ b/tests/compute/qemu/test_qemu_vm.py @@ -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 async def test_build_command_manual_uuid(vm): """