xenserver: Fix detection of xs-network-uuids in interface-reconfigure.
[openvswitch] / xenserver / etc_xensource_scripts_vif
index fcf13a690244673f282e38e3c8d3e6b05b05a52a..04aa2bb0a567e0195b516661302949fb9d447b0d 100755 (executable)
@@ -1,8 +1,6 @@
 #!/bin/sh
 
-# This file is based on /etc/xensource/script/vif from Citrix XenServer 5.0.0.
-# The original file did not contain a copyright notice or license statement.
-#
+# Copyright (C) 2008,2009 Citrix Systems, Inc. All rights reserved.
 # Copyright (C) 2009 Nicira Networks, Inc.
 
 # CA-23900: Warning: when VIFs are added to windows guests with PV drivers the backend vif device is registered,
@@ -13,7 +11,8 @@
 
 # Keep other-config/ keys in sync with device.ml:vif_udev_keys
 
-cfg_mod="/root/vswitch/bin/ovs-cfg-mod"
+cfg_mod="/usr/bin/ovs-cfg-mod"
+dump_vif_details="/usr/share/vswitch/scripts/dump-vif-details"
 service="/sbin/service"
 
 TYPE=`echo ${XENBUS_PATH} | cut -f 2 -d '/'`
@@ -32,8 +31,8 @@ handle_promiscuous()
     local arg=$(xenstore-read "${PRIVATE}/other-config/promiscuous")
     if [ $? -eq 0 -a -n "${arg}" ] ; then
         case "${arg}" in 
-            true|on) echo 1 > /sys/class/net/${vif}/brport/promisc ;;
-            *) echo 0 > /sys/class/net/${vif}/brport/promisc ;;
+            true|on) logger -t script-vif "${vif}: Promiscuous ports are not supported via vSwitch." ;;
+            *) ;;
         esac
     fi
 }
@@ -72,8 +71,8 @@ add_to_bridge()
     logger -t scripts-vif "Adding ${vif} to ${bridge} with address ${address}"
 
     vid=
-    if [ -e "/etc/openvswitch/br-$bridge" ]; then
-       . "/etc/openvswitch/br-$bridge"
+    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.$vif.tag=$VLAN_VID"
@@ -86,12 +85,17 @@ add_to_bridge()
     ${IP} link set "${vif}" address "${address}"        || logger -t scripts-vif "Failed to ip link set ${vif} address ${address}"
     ${IP} addr flush "${vif}"                           || logger -t scripts-vif "Failed to ip addr flush ${vif}"
 
+    local vif_details=$($dump_vif_details $DOMID $DEVID)
+    if [ $? -ne 0 -o -z "${vif_details}" ]; then
+           logger -t scripts-vif "Failed to retrieve vif details for vswitch"
+    fi
+
     $cfg_mod -F /etc/ovs-vswitchd.conf \
         --del-match="bridge.*.port=$vif" \
         --del-match="vlan.$vif.[!0-9]*" \
         --del-match="port.$vif.[!0-9]*" \
         --add="bridge.$bridge.port=$vif" \
-        $vid -c
+        $vid $vif_details -c 
     $service vswitch reload
 
     ${IP} link set "${vif}" up                          || logger -t scripts-vif "Failed to ip link set ${vif} up"
@@ -122,9 +126,10 @@ remove)
        xenstore-rm "${HOTPLUG}/hotplug"
        vif=vif${DOMID}.${DEVID}
        logger -t scripts-vif "${vif} has been removed"
-        $cfg_mod -vANY:console:emer -F /etc/ovs-vswitchd.conf \
-            --del-match="bridge.*.port=${vif}" \
+       $cfg_mod -vANY:console:emer -F /etc/ovs-vswitchd.conf \
+           --del-match="bridge.*.port=${vif}" \
            --del-match="vlan.${vif}.[!0-9]*" \
            --del-match="port.${vif}.[!0-9]*" -c
+       $service vswitch reload
        ;;
 esac