X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=xenserver%2Fetc_xensource_scripts_vif;h=78434fb6ccd54002a08d0f3707af54efcf5b8a18;hb=6e5fe8065cb056b3bc7f39051763480703e05496;hp=5675cdfe83b0dfc8d968d3221e4ebb54bd2c70a0;hpb=404c169247b1c3ac2ebad887f0421478a6cef924;p=sliver-openvswitch.git diff --git a/xenserver/etc_xensource_scripts_vif b/xenserver/etc_xensource_scripts_vif index 5675cdfe8..78434fb6c 100755 --- a/xenserver/etc_xensource_scripts_vif +++ b/xenserver/etc_xensource_scripts_vif @@ -145,14 +145,35 @@ remove_from_bridge() # Nothing to do ;; openvswitch) - # If ovs-brcompatd is running, it might already have deleted the - # port. Use --if-exists to suppress the error that would otherwise - # arise in that case. - $vsctl --timeout=30 -- --if-exists del-port $dev + $vsctl --timeout=30 -- del-port $dev ;; esac } +call_hook_script() { + local domid=$1 + local action=$2 + # Call the VIF hotplug hook if present + if [ -x /etc/xapi.d/vif-hotplug ]; then + local vm=$(xenstore-read "/local/domain/$domid/vm" 2>/dev/null) + if [ $? -eq 0 -a -n "${vm}" ] ; then + local vm_uuid=$(xenstore-read "$vm/uuid" 2>/dev/null) + fi + if [ -n "${vm_uuid}" ] ; then + logger -t scripts-vif "VM UUID ${vm_uuid}" + fi + + local vif_uuid=$(xenstore-read "${PRIVATE}/vif-uuid" 2>/dev/null) + if [ -n "${vif_uuid}" ] ; then + logger -t scripts-vif "VIF UUID ${vif_uuid}" + fi + if [ -n "${vif_uuid}" -a -n "${vm_uuid}" ] ; then + logger -t scripts-vif "Calling VIF hotplug hook for VM ${vm_uuid}, VIF ${vif_uuid}" + /etc/xapi.d/vif-hotplug -action "${action}" -vifuuid "${vif_uuid}" -vmuuid "${vm_uuid}" + fi + fi +} + NETWORK_MODE=$(cat /etc/xensource/network.conf) ACTION=$1 @@ -174,8 +195,13 @@ esac case ${TYPE} in vif) - DOMID=`echo ${XENBUS_PATH} | cut -f 3 -d '/'` - DEVID=`echo ${XENBUS_PATH} | cut -f 4 -d '/'` + if [ -z ${XENBUS_PATH} ]; then + DOMID=$3 + DEVID=$4 + else + DOMID=`echo ${XENBUS_PATH} | cut -f 3 -d '/'` + DEVID=`echo ${XENBUS_PATH} | cut -f 4 -d '/'` + fi dev=vif${DOMID}.${DEVID} ;; tap) @@ -213,6 +239,7 @@ online) # xs-xen.pq.hq:91e986b8e49f netback-wait-for-hotplug xenstore-write "/local/domain/0/backend/vif/${DOMID}/${DEVID}/hotplug-status" "connected" + call_hook_script $DOMID "${ACTION}" fi ;; @@ -225,8 +252,14 @@ add) remove) if [ "${TYPE}" = "vif" ] ;then xenstore-rm "${HOTPLUG}/hotplug" + call_hook_script $DOMID "${ACTION}" fi logger -t scripts-vif "${dev} has been removed" remove_from_bridge ;; + +move) + if [ "${TYPE}" = "vif" ] ;then + add_to_bridge + fi esac