Skip to content

Commit 53370ae

Browse files
fix(drivers): parse interface source by its own type, not hypervisor's
_domain2machine/_list_interfaces read a <source> element's attribute keyed by self._spec.network_type (the hypervisor's own bridge/network setting), but the boot-network port is always type='network' regardless of that setting (see the earlier create_machine fix). On a bridge-type hypervisor this made every boot-network interface look like it had no mac/source at all, breaking pool listing (and everything depending on it - pool_volume, pool_machine) for the entire hypervisor. Read the interface's own 'type' attribute instead of assuming it matches the hypervisor's network_type.
1 parent 6a91d18 commit 53370ae

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

exordos_core/compute/pool/drivers/libvirt.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,11 @@ def _domain2machine(
611611
mac_el = iface.find("mac")
612612
source_el = iface.find("source")
613613
mac = mac_el.get("address")
614-
source = source_el.get(self._spec.network_type)
614+
# The boot-network port is always type='network' regardless of
615+
# the hypervisor's own network_type (see create_machine) - read
616+
# the source attribute this specific interface actually has
617+
# ('network' or 'bridge'), not the hypervisor's configured type.
618+
source = source_el.get(iface.get("type"))
615619

616620
if not mac or not source:
617621
raise ValueError(f"Interface {iface} has no mac or source")
@@ -690,7 +694,9 @@ def _list_interfaces(self, machine: models.Machine) -> tp.List[models.Port]:
690694
mac_el = iface.find("mac")
691695
source_el = iface.find("source")
692696
mac = mac_el.get("address")
693-
source = source_el.get(self._spec.network_type)
697+
# See _domain2machine: read the source attribute this specific
698+
# interface actually has, not the hypervisor's network_type.
699+
source = source_el.get(iface.get("type"))
694700

695701
if not mac or not source:
696702
raise ValueError(f"Interface {iface} has no mac or source")

0 commit comments

Comments
 (0)