From mboxrd@z Thu Jan 1 00:00:00 1970 From: "W. Michael Petullo" Subject: Re: Proposal: vif-local Date: Mon, 9 May 2011 12:10:11 -0500 Message-ID: <20110509171011.GA15962@imp.local> References: <20110505171542.GA17115@imp.local> <1304671321.26692.117.camel@zakaz.uk.xensource.com> <20110506170602.GA4198@imp.local> <1304930722.26692.196.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="ibTvN161/egqYuK8" Return-path: Content-Disposition: inline In-Reply-To: <1304930722.26692.196.camel@zakaz.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Campbell Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org --ibTvN161/egqYuK8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline >> I have attached a patch against Xen 4.1.0 that implements a vif-post.d >> system. I only support the Linux hotplug case at this point. > The header of "${XEN_SCRIPT_DIR}/vif-post.d/00-vif-local" describes a > command line parameter "(add|remove|online|offline)" but none of the > invocations actually pass one. Since the hooks are now sourced they no longer take parameters. It is, in fact, a shell variable and I have updated the comments. > I think it would be better to encapsulate the functionality in a > "call_hooks " function in > xen-hotplug-common.sh, calling it as "call_hooks vif post ..." rather > than open coding that loop everywhere. Good idea. Implemented. > I think generally it is a good idea to have an explicit suffix (e.g. > ".hook") for this sort of thing since then you can use *.hook to get the > list of files which saves manually filtering out *~ *.rpmsave *.dpkg-bak > *.disabled-by-admin *.some-random-suffix-intended-to-disable-the-script > etc. Implemented. > You probably want to quote $f in case some nutter uses a space in the > hook filename. Implemented. > You don't actually install 00-vif-local but I think that's a good thing > since the default is an empty script so we save a fork/exec by not > running it. Good. > Lastly we need a Signed-off-by per the DCO (section 11 of > http://lwn.net/Articles/139918/) as well as a suitable changelog message > before we can apply any patch. Please see the attached patch. Allow for site-specific hooks that will be executed after Xen initializes a vif. This allows an administrator to specify custom firewall rules or other special configuration parameters. Signed-off-by: W. Michael Petullo -- Mike :wq --ibTvN161/egqYuK8 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="xen-4.1.0-local-vif-scripts-1.patch" diff -u --recursive --new-file xen-4.1.0-vanilla/tools/hotplug/Linux/vif-bridge xen-4.1.0/tools/hotplug/Linux/vif-bridge --- xen-4.1.0-vanilla/tools/hotplug/Linux/vif-bridge 2011-05-06 10:39:15.848610384 -0500 +++ xen-4.1.0/tools/hotplug/Linux/vif-bridge 2011-05-09 11:47:03.247718082 -0500 @@ -105,6 +105,8 @@ 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 -u --recursive --new-file xen-4.1.0-vanilla/tools/hotplug/Linux/vif-nat xen-4.1.0/tools/hotplug/Linux/vif-nat --- xen-4.1.0-vanilla/tools/hotplug/Linux/vif-nat 2011-05-06 10:39:15.847610424 -0500 +++ xen-4.1.0/tools/hotplug/Linux/vif-nat 2011-05-09 11:47:11.815394984 -0500 @@ -185,6 +185,8 @@ handle_iptable +call_hooks vif post + log debug "Successful vif-nat $command for ${dev}." if [ "$command" = "online" ] then diff -u --recursive --new-file xen-4.1.0-vanilla/tools/hotplug/Linux/vif-post.d/00-vif-local.hook xen-4.1.0/tools/hotplug/Linux/vif-post.d/00-vif-local.hook --- xen-4.1.0-vanilla/tools/hotplug/Linux/vif-post.d/00-vif-local.hook 1969-12-31 18:00:00.000000000 -0600 +++ xen-4.1.0/tools/hotplug/Linux/vif-post.d/00-vif-local.hook 2011-05-09 11:21:12.438113611 -0500 @@ -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 -u --recursive --new-file xen-4.1.0-vanilla/tools/hotplug/Linux/vif-route xen-4.1.0/tools/hotplug/Linux/vif-route --- xen-4.1.0-vanilla/tools/hotplug/Linux/vif-route 2011-05-06 10:39:15.845610504 -0500 +++ xen-4.1.0/tools/hotplug/Linux/vif-route 2011-05-09 11:46:57.408939221 -0500 @@ -49,6 +49,8 @@ handle_iptable +call_hooks vif post + log debug "Successful vif-route ${command} for ${dev}." if [ "${command}" = "online" ] then diff -u --recursive --new-file xen-4.1.0-vanilla/tools/hotplug/Linux/xen-hotplug-common.sh xen-4.1.0/tools/hotplug/Linux/xen-hotplug-common.sh --- xen-4.1.0-vanilla/tools/hotplug/Linux/xen-hotplug-common.sh 2011-05-06 10:39:15.847610424 -0500 +++ xen-4.1.0/tools/hotplug/Linux/xen-hotplug-common.sh 2011-05-09 11:43:09.239663639 -0500 @@ -99,4 +99,15 @@ _xenstore_write "$@" || fatal "Writing $@ to xenstore failed." } +## +# call_hooks +# +# Execute each hook in the directory. +# +call_hooks() { + for f in /etc/xen/scripts/${1}-${2}.d/*.hook; do + [ -x "$f" ] && . "$f" + done +} + log debug "$@" "XENBUS_PATH=$XENBUS_PATH" --ibTvN161/egqYuK8 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --ibTvN161/egqYuK8--