[ovs-dev] xenserver: use ovs-vsctl for VIF VLAN configuration instead of /var/lib/openvswitch/br-*

Ian Campbell Ian.Campbell at citrix.com
Mon Oct 5 15:32:53 UTC 2009


ovs-vsctl did not exist when this code was originally written, but it
provides exactly what is needed to get rid of those separate state
files.

The vif hotplug script diff is against the xs5.7 branch but I think is
applicable to master and/or citrix with just context changes.

I was thinking of using ovs-vsctl exclusively for configuration
modifications from the vif hotplug script but that would need a
mechanism to pass the additional vif details to ovs-vsctl add-port as
well as perhaps making the bridge optional to del-port. The other option
would be to use the --no-reload option and split the config mods into
two parts, but I don't like that idea much.

Ian.

diff -r 71d4aa90af38 scripts/interface-reconfigure
--- a/scripts/interface-reconfigure	Mon Oct 05 15:32:53 2009 +0100
+++ b/scripts/interface-reconfigure	Mon Oct 05 15:56:05 2009 +0100
@@ -1474,17 +1474,6 @@
         cfgmod_argv += ['--add=vlan.%s.tag=%s' % (ipdev, pifrec['VLAN'])]
         cfgmod_argv += ['--add=iface.%s.internal=true' % (ipdev)]
         cfgmod_argv += ['--add=iface.%s.fake-bridge=true' % (ipdev)]
-        if not os.path.exists(vswitch_state_dir):
-            os.mkdir(vswitch_state_dir)
-        br = ConfigurationFile("br-%s" % ipdev, vswitch_state_dir)
-        br.write("VLAN_SLAVE=%s\n" % bridge)
-        br.write("VLAN_VID=%s\n" % pifrec['VLAN'])
-        br.close()
-        f.attach_child(br)
-    else:
-        br = ConfigurationFile("br-%s" % ipdev, vswitch_state_dir)
-        br.unlink()
-        f.attach_child(br)
         
     # Apply updated configuration.
     try:
diff -r 71d4aa90af38 scripts/vif
--- a/scripts/vif	Mon Oct 05 15:32:53 2009 +0100
+++ b/scripts/vif	Mon Oct 05 15:56:05 2009 +0100
@@ -12,6 +12,7 @@
 # Keep other-config/ keys in sync with device.ml:vif_udev_keys
 
 cfg_mod="/usr/bin/ovs-cfg-mod"
+vsctl="/usr/bin/ovs-vsctl"
 service="/sbin/service"
 IP="/sbin/ip"
 
@@ -89,13 +90,11 @@
     fi
     logger -t scripts-vif "Adding ${dev} to ${bridge} with address ${address}"
 
-    vid=
-    if [ -e "/var/lib/openvswitch/br-$bridge" ]; then
-	. "/var/lib/openvswitch/br-$bridge"
-	if [ -n "$VLAN_SLAVE" -a -n "$VLAN_VID" ]; then
-	    bridge=$VLAN_SLAVE
-	    vid="--add=vlan.${dev}.tag=$VLAN_VID"
-	fi
+    local VLAN_ID=$($vsctl br-to-vlan $bridge)
+    local vid=
+    if [ "$VLAN_ID" -ne 0 ] ; then
+	bridge=$($vsctl br-to-parent $bridge)
+	vid="--add=vlan.${dev}.tag=${VLAN_ID}"
     fi
 
     if [ "$type" = "vif" ] ; then






More information about the dev mailing list