xenserver: Give tap devices iface-ids.
authorEthan Jackson <ethan@nicira.com>
Thu, 16 Jun 2011 22:02:50 +0000 (15:02 -0700)
committerEthan Jackson <ethan@nicira.com>
Fri, 17 Jun 2011 19:55:56 +0000 (12:55 -0700)
In some cases XenServer will give a virtual machine a tap device in
addition to its usual vif.  These tap devices need iface-ids so
that controllers can figure out which vif they are related to.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync

index d1ccc6f708b9df4b9a01a60c84d2d8b9d87d7957..ef10ce792338fd16a16db8187f6f1391529c47ee 100755 (executable)
@@ -99,7 +99,7 @@ def get_bridge_id(br_name, default=None):
 # "nicira-iface-id" key in the "other_config" field of the VIF
 # record of XAPI.
 def get_iface_id(if_name, xs_vif_uuid):
-    if not if_name.startswith("vif"):
+    if not if_name.startswith("vif") and not if_name.startswith("tap"):
         # Treat whatever was passed into 'xs_vif_uuid' as a default
         # value for non-VIFs.
         return xs_vif_uuid
@@ -297,6 +297,17 @@ def main(argv):
             new_interfaces[name] = {"xs-vif-uuid": xs_vif_uuid,
                                     "iface-id": iface_id}
 
+        #Tap devices take their xs-vif-uuid from their corresponding vif
+        for name in new_interfaces:
+            if not name.startswith("tap"):
+                continue
+
+            vif = name.replace("tap", "vif", 1)
+
+            if vif in new_interfaces:
+                xs_vif_uuid = new_interfaces[vif]["xs-vif-uuid"]
+                new_interfaces[name]["xs-vif-uuid"] = xs_vif_uuid
+
         if bridges != new_bridges:
             for name,ids in new_bridges.items():
                 if name not in bridges: