+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
+}
+