NE: persist OVN broadcast/isolation URI on NIC for vif.binding=lswitch

Delta 1 already overrides nic.setBroadcastType(Lswitch) on the
NicProfile during prepare() so the KVM agent picks the OVS Lswitch
path. But the underlying nics row still carried the cosmetic
``vlan://<id>`` URI allocated by GuestNetworkGuru at design-time, which
is misleading on listNics / DB queries: a NIC sitting on an OVN
logical switch should not advertise a VLAN URI.

Override broadcast_uri and isolation_uri on the NicProfile to
``ovn://cs-net-<networkId>`` (the convention used by the legacy
ovn-plugin) and persist the same on the nics row via nicDao.update.
The VLAN that the guru allocated stays as a ghost in
op_dc_vnet_alloc -- it is never used on the wire because the VIF
attaches to br-int and traffic flows through OVN's logical pipeline
over geneve. Releasing the VLAN back to the pool would require
intercepting the design phase, which is out of scope for this hook.

Verified end-to-end: i-2-24-VM on network 214 now lists

   broadcast_uri = ovn://cs-net-214
   isolation_uri = ovn://cs-net-214

and the OVN NB LSP / OVS iface-id / OVN SB Port_Binding remain
correctly bound to the chassis, as before.
This commit is contained in:
Marco Sinhoreli 2026-05-03 12:21:27 +02:00 committed by Wei Zhou
parent 0edce199a0
commit c3aaf658b1
1 changed files with 26 additions and 1 deletions

View File

@ -518,8 +518,33 @@ public class NetworkExtensionElement extends AdapterBase implements
// libvirt sets external_ids:iface-id atomically with tap creation.
// No agent patch is required for this binding mode.
if (isLswitchVifBinding(network)) {
// Override broadcast type + URI on the NicProfile (in-memory),
// and persist the same to the underlying nics row so listNics
// / DB queries report consistent OVN identifiers instead of
// the stale VLAN URI the GuestNetworkGuru allocated at
// design-time.
java.net.URI ovnUri = null;
try {
ovnUri = java.net.URI.create("ovn://cs-net-" + network.getId());
} catch (Exception e) {
logger.warn("Failed to build OVN URI for NIC {}: {}", nic.getId(), e.getMessage());
}
nic.setBroadcastType(Networks.BroadcastDomainType.Lswitch);
logger.debug("prepare: applied Lswitch broadcast type to NIC {} (uuid={}) on network {} per extension vif.binding hint",
if (ovnUri != null) {
nic.setBroadcastUri(ovnUri);
nic.setIsolationUri(ovnUri);
try {
com.cloud.vm.NicVO nicVo = nicDao.findById(nic.getId());
if (nicVo != null) {
nicVo.setBroadcastUri(ovnUri);
nicVo.setIsolationUri(ovnUri);
nicDao.update(nicVo.getId(), nicVo);
}
} catch (Exception e) {
logger.warn("Failed to persist OVN URI on nics row {}: {}", nic.getId(), e.getMessage());
}
}
logger.debug("prepare: applied Lswitch broadcast type and ovn:// URI to NIC {} (uuid={}) on network {} per extension vif.binding hint",
nic.getId(), nic.getUuid(), network.getId());
}