mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-10-25 11:22:26 +02:00
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 <noreply@anthropic.com>
This commit is contained in:
parent
4d55cb1b9c
commit
b9cf9158ca
@ -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 {}
|
||||
|
||||
@ -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):
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user