From b9cf9158cae6972ad630345f7d8c5ec1c9f44b26 Mon Sep 17 00:00:00 2001 From: tikD1337 <199419268+tikD1337@users.noreply.github.com> Date: Fri, 23 Oct 2026 09:56:48 +0200 Subject: [PATCH] fix(compute): ignore null settings of custom adapters When only a port is renamed in a template's custom adapters, the adapter is saved with "adapter_type": null. The emulators read it with custom_adapter.get("adapter_type", self._adapter_type), which returns None for a key set to null: QEMU was then started with "-device None,..." and died ("'None' is not a valid device model name"), GNS3 only reporting "Could not start Telnet QEMU console". VirtualBox and VMware read the adapter type the same way. Drop the null settings in _get_custom_adapter_settings so the node's own adapter type (and MAC address) applies. Co-Authored-By: Claude Opus 5.5 --- gns3server/compute/base_node.py | 4 +++- tests/compute/qemu/test_qemu_vm.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gns3server/compute/base_node.py b/gns3server/compute/base_node.py index 0913e1758..90bab3c25 100644 --- a/gns3server/compute/base_node.py +++ b/gns3server/compute/base_node.py @@ -1561,5 +1561,7 @@ class BaseNode: if self.custom_adapters: for custom_adapter in self.custom_adapters: if custom_adapter["adapter_number"] == adapter_number: - return custom_adapter + # settings left unset are null (e.g. "adapter_type" when only the + # port is renamed): drop them so callers fall back to the node's own + return {key: value for key, value in custom_adapter.items() if value is not None} return {} diff --git a/tests/compute/qemu/test_qemu_vm.py b/tests/compute/qemu/test_qemu_vm.py index f48418d4b..4d154a3e2 100644 --- a/tests/compute/qemu/test_qemu_vm.py +++ b/tests/compute/qemu/test_qemu_vm.py @@ -798,6 +798,21 @@ async def test_build_command_with_virtio_net_pci_adapter(vm): assert "virtio-net-pci,mac=00:00:ab:0e:0f:09,speed=10000,duplex=full,bus=pci-bridge1,addr=0x00,netdev=gns3-0" in cmd +@pytest.mark.asyncio +async def test_build_command_custom_adapter_without_type(vm): + """ + A custom adapter that only renames a port is saved with "adapter_type": null: + the node's adapter type applies instead of "-device None", which QEMU rejects. + """ + + vm.adapters = 1 + vm.mac_address = "00:00:ab:0e:0f:09" + vm.custom_adapters = [{"adapter_number": 0, "port_name": "sfp1", "adapter_type": None, "mac_address": None}] + with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()): + cmd = await vm._build_command() + assert "e1000,mac=00:00:ab:0e:0f:09,bus=pci-bridge1,addr=0x00,netdev=gns3-0" in cmd + + @pytest.mark.asyncio async def test_build_command_with_invalid_options(vm):