]> xenbits.xensource.com Git - xen.git/commitdiff
hotplug: add FreeBSD vif-bridge
authorRoger Pau Monne <roger.pau@citrix.com>
Mon, 2 Jun 2014 15:08:17 +0000 (17:08 +0200)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 18 Jun 2014 16:19:10 +0000 (17:19 +0100)
Add a simple vif-bridge script, that takes care of adding network
backends (tap or xnb) to a pre-configured bridge.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/hotplug/FreeBSD/Makefile
tools/hotplug/FreeBSD/vif-bridge [new file with mode: 0644]

index c7ffc5140146be7fd2f42a4ac0e529af227900e9..6480aa5d894996a5d7d9b8b1bd891c403d43d702 100644 (file)
@@ -2,7 +2,7 @@ XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 # Xen script dir and scripts to go there.
-XEN_SCRIPTS =
+XEN_SCRIPTS = vif-bridge
 
 XEN_SCRIPT_DATA =
 
diff --git a/tools/hotplug/FreeBSD/vif-bridge b/tools/hotplug/FreeBSD/vif-bridge
new file mode 100644 (file)
index 0000000..fa7570d
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh -e
+#
+# FreeBSD hotplug script for attaching xnb* interfaces to bridges
+#
+# Parameters:
+#      $1: xenstore backend path of the vif
+#      $2: action, either "add" or "remove"
+#
+# Environment variables:
+#      $iface_dev: name of the backend device (xnb<domid>.<handle>)
+#
+
+DIR=$(dirname "$0")
+. "${DIR}/hotplugpath.sh"
+
+PATH=${BINDIR}:${SBINDIR}:${LIBEXEC}:${PRIVATE_BINDIR}:/bin:/usr/bin:/sbin:/usr/sbin
+export PATH
+
+path=$1
+action=$2
+
+case $action in
+add)
+       bridge=$(xenstore-read "$path/bridge")
+       ifconfig $bridge addm $iface_dev
+       ifconfig $iface_dev up
+       exit 0
+       ;;
+remove)
+       if [ "$emulated" -eq 1 ]; then
+               bridge=$(xenstore-read "$path/bridge")
+               ifconfig $iface_dev down
+               ifconfig $bridge deletem $iface_dev
+               ifconfig $iface_dev destroy
+       fi
+       exit 0
+       ;;
+*)
+       exit 0
+       ;;
+esac