X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=xenserver%2Fetc_xensource_scripts_vif;h=78434fb6ccd54002a08d0f3707af54efcf5b8a18;hb=acfb4e95970bc6ff851fd21a7f055f503faca144;hp=062549862e3f3e0628cd54d28f27bbcbaa8a9df8;hpb=490df1ef184f4a506aa1837e35179e3f340be8d0;p=sliver-openvswitch.git diff --git a/xenserver/etc_xensource_scripts_vif b/xenserver/etc_xensource_scripts_vif index 062549862..78434fb6c 100755 --- a/xenserver/etc_xensource_scripts_vif +++ b/xenserver/etc_xensource_scripts_vif @@ -150,6 +150,30 @@ remove_from_bridge() 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 @@ -171,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) @@ -210,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 ;; @@ -222,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