]> git.pld-linux.org Git - packages/xen.git/commitdiff
- add support for openvswitch auto/th/xen-4.2.1-3
authorJan Rękorajski <baggins@pld-linux.org>
Wed, 10 Apr 2013 12:38:38 +0000 (14:38 +0200)
committerJan Rękorajski <baggins@pld-linux.org>
Wed, 10 Apr 2013 12:38:38 +0000 (14:38 +0200)
- rel 3

vif-openvswitch [new file with mode: 0755]
xen.spec

diff --git a/vif-openvswitch b/vif-openvswitch
new file mode 100755 (executable)
index 0000000..142b154
--- /dev/null
@@ -0,0 +1,79 @@
+#!/bin/bash
+#============================================================================
+# ${XEN_SCRIPT_DIR}/vif-openvswitch
+#
+# Script for configuring a vif using Open vSwitch.
+#
+# Usage:
+# vif-openvswitch (add|remove|online|offline)
+#
+# Environment vars:
+# vif         vif interface name (required).
+# XENBUS_PATH path to this device's details in the XenStore (required).
+#
+# Read from the store:
+# bridge  bridge to add the vif to (optional).  Defaults to searching for the
+#         bridge itself.
+#
+# up:
+# Enslaves the vif interface to the bridge.
+#
+# down:
+# Removes the vif interface from the bridge.
+#============================================================================
+
+dir=$(dirname "$0")
+. "$dir/vif-common.sh"
+
+bridge=${bridge:-}
+bridge=$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge")
+
+if [ -z "${bridge}" ]; then
+       bridge=$(ovs-vsctl list-br | head -n 1)
+       if [ -z "$bridge" ]; then
+               fatal "Could not find bridge, and none was specified"
+       fi
+fi
+
+tag=${tag:-}
+
+# Domain on VLAN tagged bridge?
+if ! ovs-vsctl br-exists ${bridge}; then
+       if [[ $bridge =~ \.[[:digit:]]{1,4}$ ]]; then
+               tag=${bridge##*.}
+               bridge=${bridge%.[0-9]*}
+       else
+               fatal "Could not find bridge device ${bridge}"
+       fi
+fi
+
+if ! ovs-vsctl br-exists ${bridge}; then
+       fatal "Could not find bridge device ${bridge}"
+fi
+
+case "$command" in
+  online|add)
+       ip link set dev "${vif}" up
+       if [ -z $tag ]; then
+               ovs-vsctl -- --may-exist add-port ${bridge} ${vif}
+       else
+               ovs-vsctl -- --may-exist add-port ${bridge} ${vif} tag=${tag}
+       fi
+       ;;
+  offline)
+       do_without_error ovs-vsctl -- --if-exists del-port ${bridge} ${vif}
+       do_without_error ip link set dev "${vif}" down
+       ;;
+esac
+
+call_hooks vif post
+
+if [ -z "${tag}" ]; then
+       log debug "Successful vif-openvswitch $command for ${vif}, bridge ${bridge}."
+else
+       log debug "Successful vif-openvswitch $command for ${vif}, bridge ${bridge}, tag ${tag}."
+fi
+
+if [ "$command" == "online" ]; then
+       success
+fi
index 287ab6b72a16b60dc9f42cb51e62d712afdb5e17..d3a7fd02826c53a19ecbb53ca92907d3bfa4a982 100644 (file)
--- a/xen.spec
+++ b/xen.spec
@@ -30,7 +30,7 @@ Summary:      Xen - a virtual machine monitor
 Summary(pl.UTF-8):     Xen - monitor maszyny wirtualnej
 Name:          xen
 Version:       4.2.1
-Release:       2
+Release:       3
 License:       GPL v2, interface parts on BSD-like
 Group:         Applications/System
 Source0:       http://bits.xensource.com/oss-xen/release/%{version}/%{name}-%{version}.tar.gz
@@ -75,6 +75,7 @@ Source55:     xen.logrotate
 Source56:      xen.tmpfiles
 Source57:      xen.cfg
 Source58:      xen.efi-boot-update
+Source59:      vif-openvswitch
 Patch0:                %{name}-python_scripts.patch
 Patch1:                %{name}-symbols.patch
 Patch2:                %{name}-curses.patch
@@ -467,6 +468,8 @@ sed -e's;@libdir@;%{_libdir};g' -e's;@target_cpu@;%{_target_cpu};g' \
 
 mv $RPM_BUILD_ROOT/etc/xen/{x{m,l}example*,examples}
 
+install %{SOURCE59} $RPM_BUILD_ROOT%{_sysconfdir}/xen/scripts/vif-openvswitch
+
 # for %%doc
 install -d _doc
 for tool in blktap blktap2 pygrub xenmon ; do
This page took 0.105561 seconds and 4 git commands to generate.