xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "W. Michael Petullo" <mike@flyn.org>
To: Ian Campbell <Ian.Campbell@eu.citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: Proposal: vif-local
Date: Mon, 9 May 2011 12:10:11 -0500	[thread overview]
Message-ID: <20110509171011.GA15962@imp.local> (raw)
In-Reply-To: <1304930722.26692.196.camel@zakaz.uk.xensource.com>

[-- Attachment #1: Type: text/plain, Size: 1757 bytes --]

>> 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 <devtype> <hook> <other args...>" 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@flyn.org>

-- 
Mike

:wq

[-- Attachment #2: xen-4.1.0-local-vif-scripts-1.patch --]
[-- Type: text/plain, Size: 3256 bytes --]

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 <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"

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

  reply	other threads:[~2011-05-09 17:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-21  7:04 New 4.0.2 and 4.1.1 release candidates Keir Fraser
2011-05-24  7:24 ` Keir Fraser
2011-05-24 14:17   ` W. Michael Petullo
2011-05-05 17:15     ` Proposal: vif-local W. Michael Petullo
2011-05-06  8:42       ` Ian Campbell
2011-05-06 17:06         ` W. Michael Petullo
2011-05-09  8:45           ` Ian Campbell
2011-05-09 17:10             ` W. Michael Petullo [this message]
2011-05-10  8:02               ` Ian Campbell
2011-05-10 16:06                 ` W. Michael Petullo
2011-05-10 16:12                   ` Ian Campbell
2011-05-24 17:31                 ` Proposal: vif-local [and 1 more messages] Ian Jackson
2011-05-24 17:51                   ` Ian Campbell
2011-05-25  9:45                     ` Ian Jackson
2011-05-24 15:49     ` Re: New 4.0.2 and 4.1.1 release candidates Keir Fraser
2011-05-24 16:13 ` Olaf Hering
2011-05-24 17:58   ` Keir Fraser
2011-05-24 18:25     ` Olaf Hering
2011-05-24 20:04       ` Keir Fraser
2011-05-26  8:36     ` George Dunlap
2011-05-26  9:09       ` Keir Fraser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110509171011.GA15962@imp.local \
    --to=mike@flyn.org \
    --cc=Ian.Campbell@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).