Skip to content

Commit 9100fe5

Browse files
fix(drivers): boot port must always use network-type interface
LibvirtPoolDriver.create_machine() applied the hypervisor's own network_type (bridge/network) to every port it's given, including the initial boot-network port. The boot network is always a plain libvirt virtual network regardless of the hypervisor's main network type, so on a bridge-type hypervisor libvirt tried to treat the boot network's name as a literal host bridge device name and rejected it as too long for IFNAMSIZ. Only force type='network' for the boot-network port specifically (identified via the new BOOT_NETWORK_PORT_UUID sentinel, see Port.from_boot_network()). Any other port - including the real port(s) create_machine() is given when recreate_machine() rebuilds the domain post-flash - keeps honoring network_type, since real bridge-type hypervisors do use raw bridge-type interfaces (source=<bridge device>), not a libvirt network wrapping one. attach_port(), used only for the real port, is unaffected.
1 parent 4e3dee2 commit 9100fe5

3 files changed

Lines changed: 20 additions & 15 deletions

File tree

exordos_core/compute/constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626

2727
NODE_SET_PROJECT = sys_uuid.UUID("11111113-bc70-4760-9fbf-9fcfe40da329")
2828

29+
# Sentinel UUID for the transient boot-network port (see
30+
# Port.from_boot_network()) - a real UUID doesn't make sense for it since
31+
# it's replaced once the machine is flashed.
32+
BOOT_NETWORK_PORT_UUID = sys_uuid.UUID("00000000-0000-0000-0000-000000000000")
33+
2934

3035
BootType = tp.Literal["hd", "network", "cdrom"]
3136

exordos_core/compute/dm/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -766,9 +766,9 @@ def from_boot_network(cls):
766766
}
767767
)
768768
return cls(
769-
# The UUID is not important for port in boot network.
770-
# It is just a placeholder.
771-
uuid=sys_uuid.UUID("00000000-0000-0000-0000-000000000000"),
769+
# The pool driver relies on this specific UUID to recognize the
770+
# port as the transient boot network (see LibvirtPoolDriver).
771+
uuid=nc.BOOT_NETWORK_PORT_UUID,
772772
project_id=cc.SERVICE_PROJECT_ID,
773773
name="bootnet_port",
774774
subnet=boot_subnet.uuid,

exordos_core/compute/pool/drivers/libvirt.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,13 +1198,8 @@ def attach_port(self, machine: models.Machine, port: models.Port) -> None:
11981198
raise
11991199

12001200
# Build interface XML
1201-
# Always type='network': `port.source` is the logical libvirt
1202-
# network name the orchestrator tracks (see create_machine), not
1203-
# necessarily a literal host bridge device - a bridge-type
1204-
# hypervisor still needs it resolved through a local libvirt
1205-
# network that forwards onto the real bridge.
12061201
interface_xml = XMLLibvirtInstance.interface_xml(
1207-
iface_type="network",
1202+
iface_type=self._spec.network_type,
12081203
mac=port.mac,
12091204
rom=self._spec.iface_rom_file,
12101205
mtu=self._spec.iface_mtu,
@@ -1303,12 +1298,17 @@ def create_machine(
13031298
mac=port.mac,
13041299
rom=self._spec.iface_rom_file,
13051300
mtu=self._spec.iface_mtu,
1306-
# Always type='network': `port.source` is a logical
1307-
# libvirt network name the orchestrator tracks (the boot
1308-
# network at initial creation, or the main network when
1309-
# recreate_machine() rebuilds the domain post-flash), not
1310-
# necessarily a literal host bridge device.
1311-
iface_type="network",
1301+
# The boot-network port (see Port.from_boot_network()) is
1302+
# always a transient libvirt-managed network, regardless of
1303+
# the hypervisor's own network_type - unlike the real
1304+
# port(s) attached once the machine is flashed
1305+
# (recreate_machine()), which must honor it (e.g. a raw
1306+
# host bridge on bridge-type hypervisors).
1307+
iface_type=(
1308+
"network"
1309+
if port.uuid == nc.BOOT_NETWORK_PORT_UUID
1310+
else self._spec.network_type
1311+
),
13121312
source=port.source,
13131313
)
13141314

0 commit comments

Comments
 (0)