[ovs-dev] [PATCH] xenserver: Fix up iface-id after it changes or disappears too.

Ben Pfaff blp at nicira.com
Fri Apr 1 20:48:06 UTC 2011

ovs-xapi-sync is supposed to always keep external-ids:iface-id up to date,
but in fact it would only set it when an interface initially appeared.  If
the interface quickly disappeared and reappeared, then it failed to notice
that iface-id had changed or disappeared.  This happens in practice on
Citrix XenServer, where VM "tap" devices often disappear and then reappear
almost immediately during VM boot.  This commit fixes the problem.

This also fixes the similar problem for external-ids:bridge-id in Bridge
records.  Bridges aren't ordinarily destroyed and re-created quickly, so
this problem might never have manifested in practice for bridges.

Many thanks to Reid Price <reid at nicira.com> for identifying the problem
and supplying an initial fix.

Bug #5239.
Reported-by: Henrik Amren <henrik at nicira.com>
 .../usr_share_openvswitch_scripts_ovs-xapi-sync    |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
index 4d82b99..07995d0 100755
--- a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
+++ b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync
@@ -176,11 +176,13 @@ def update_bridge_id(name, ids):
     if ids.get("bridge-id") != primary_id:
         set_external_id("Bridge", name, "bridge-id", primary_id)
+        ids["bridge-id"] = primary_id
 def update_iface_id(name, ids):
     id = get_iface_id(name, ids.get("xs-vif-uuid"))
     if ids.get("iface-id") != id and id:
         set_external_id("Interface", name, "iface-id", id)
+        ids["iface-id"] = id
 def keep_table_columns(schema, table_name, column_types):
     table = schema.tables.get(table_name)
@@ -285,13 +287,17 @@ def main(argv):
         for rec in idl.data["Bridge"].itervalues():
             name = rec.name.as_scalar()
             xs_network_uuids = rec.external_ids.get("xs-network-uuids")
-            new_bridges[name] = {"xs-network-uuids": xs_network_uuids}
+            bridge_id = rec.external_ids.get("bridge-id")
+            new_bridges[name] = {"xs-network-uuids": xs_network_uuids,
+                                 "bridge-id": bridge_id}
         new_interfaces = {}
         for rec in idl.data["Interface"].itervalues():
             name = rec.name.as_scalar()
             xs_vif_uuid = rec.external_ids.get("xs-vif-uuid")
-            new_interfaces[name] = {"xs-vif-uuid": xs_vif_uuid}
+            iface_id = rec.external_ids.get("iface-id")
+            new_interfaces[name] = {"xs-vif-uuid": xs_vif_uuid,
+                                    "iface-id": iface_id}
         if bridges != new_bridges:
             for name,ids in new_bridges.items():

More information about the dev mailing list