aboutsummaryrefslogtreecommitdiffstats
path: root/tools/hotplug
diff options
context:
space:
mode:
authorW. Michael Petullo <mike@flyn.org>2011-05-25 10:45:24 +0100
committerW. Michael Petullo <mike@flyn.org>2011-05-25 10:45:24 +0100
commit8b917cf2d04c187f1fbfc1363d9c962bfbd7434c (patch)
tree55e211a403c2291d322e2bf4ab54f94d1b8a4413 /tools/hotplug
parent037f0cea24451eb444c756b57ad13e0768292e82 (diff)
downloadxen-8b917cf2d04c187f1fbfc1363d9c962bfbd7434c.tar.gz
xen-8b917cf2d04c187f1fbfc1363d9c962bfbd7434c.tar.bz2
xen-8b917cf2d04c187f1fbfc1363d9c962bfbd7434c.zip
tools/hotplug: support vif-post.d hook arrangements
New feature: you can drop hook scripts into /etc/xen/scripts/vif-post.d/*.hook Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/hotplug')
-rw-r--r--tools/hotplug/Linux/vif-bridge2
-rw-r--r--tools/hotplug/Linux/vif-nat2
-rw-r--r--tools/hotplug/Linux/vif-post.d/00-vif-local.hook18
-rw-r--r--tools/hotplug/Linux/vif-route2
-rw-r--r--tools/hotplug/Linux/xen-hotplug-common.sh11
5 files changed, 35 insertions, 0 deletions
diff --git a/tools/hotplug/Linux/vif-bridge b/tools/hotplug/Linux/vif-bridge
index 1498805379..f48951935a 100644
--- a/tools/hotplug/Linux/vif-bridge
+++ b/tools/hotplug/Linux/vif-bridge
@@ -105,6 +105,8 @@ if [ "$type_if" = vif ]; then
handle_iptable
fi
+call_hooks vif post
+
log debug "Successful vif-bridge $command for $dev, bridge $bridge."
if [ "$type_if" = vif -a "$command" = "online" ]
then
diff --git a/tools/hotplug/Linux/vif-nat b/tools/hotplug/Linux/vif-nat
index 9082cc96bb..8d29fb6ea2 100644
--- a/tools/hotplug/Linux/vif-nat
+++ b/tools/hotplug/Linux/vif-nat
@@ -185,6 +185,8 @@ esac
handle_iptable
+call_hooks vif post
+
log debug "Successful vif-nat $command for ${dev}."
if [ "$command" = "online" ]
then
diff --git a/tools/hotplug/Linux/vif-post.d/00-vif-local.hook b/tools/hotplug/Linux/vif-post.d/00-vif-local.hook
new file mode 100644
index 0000000000..d7d44535e2
--- /dev/null
+++ b/tools/hotplug/Linux/vif-post.d/00-vif-local.hook
@@ -0,0 +1,18 @@
+#============================================================================
+# ${XEN_SCRIPT_DIR}/vif-post.d/00-vif-local.hook
+#
+# Script for performing local configuration of a vif.
+# This script will be sourced by, e.g., vif-bridge after the hotplugging
+# system calls vif-bridge. The script is here and not simply executed as
+# a udev rule because this allows simple access to several environment
+# variables set by the calling vif-* script.
+#
+# Environment vars:
+# command (add|remove|online|offline)
+# dev vif interface name (required).
+# main_ip IP address of Dom0
+# ip list of IP networks for the vif, space-separated
+# XENBUS_PATH path to this device's details in the XenStore (required).
+#============================================================================
+
+# Place local modifications here.
diff --git a/tools/hotplug/Linux/vif-route b/tools/hotplug/Linux/vif-route
index 6c5587afd5..02f1403a54 100644
--- a/tools/hotplug/Linux/vif-route
+++ b/tools/hotplug/Linux/vif-route
@@ -49,6 +49,8 @@ fi
handle_iptable
+call_hooks vif post
+
log debug "Successful vif-route ${command} for ${dev}."
if [ "${command}" = "online" ]
then
diff --git a/tools/hotplug/Linux/xen-hotplug-common.sh b/tools/hotplug/Linux/xen-hotplug-common.sh
index 370f9ade2f..95beab0ec5 100644
--- a/tools/hotplug/Linux/xen-hotplug-common.sh
+++ b/tools/hotplug/Linux/xen-hotplug-common.sh
@@ -99,4 +99,15 @@ xenstore_write() {
_xenstore_write "$@" || fatal "Writing $@ to xenstore failed."
}
+##
+# call_hooks <devtype> <hook>
+#
+# Execute each hook in the <hook> directory.
+#
+call_hooks() {
+ for f in /etc/xen/scripts/${1}-${2}.d/*.hook; do
+ [ -x "$f" ] && . "$f"
+ done
+}
+
log debug "$@" "XENBUS_PATH=$XENBUS_PATH"