1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-09 11:46:49 +00:00

fix(interfaces): deleting a bridge keeps the devices it held

With the netcf backend (RHEL/AlmaLinux 8), undefining a bridge also
removes its members' configuration: the device came back without any
after a reboot. Like virsh iface-unbridge, each member is now defined
again on its own after the bridge is undefined, with the bridge's start
mode and, when it is the only member, its addresses. A bond keeps its
mode and devices.

Checked on AlmaLinux 8 (libvirt 8.0, netcf): an ethernet and a bond
member get their ifcfg back, and the bond comes up with the address
after a reboot.
This commit is contained in:
catborise 2026-10-18 21:43:00 +03:00
parent 7526e9ab32
commit 28a73519d7
3 changed files with 53 additions and 0 deletions

View file

@ -198,4 +198,12 @@ class wvmInterface(wvmConnect):
self.iface.create()
def delete_iface(self):
"""Undefine the interface. netcf removes a bridge's members with it, so
each member is defined again on its own, as virsh iface-unbridge does:
with the bridge's start mode and, when it is the only one, addresses."""
tree = ElementTree.fromstring(self._XMLDesc(VIR_INTERFACE_XML_INACTIVE))
members = tree.findall("bridge/interface")
self.iface.undefine()
for member in members:
member.extend(tree.findall("start") + (tree.findall("protocol") if len(members) == 1 else []))
self.wvm.interfaceDefineXML(ElementTree.tostring(member, encoding="unicode"), 0)