[lxc-devel] [PATCH] add lxc.network.script(.pre|.post|) configuration hooks

Stefan Tomanek stefan.tomanek at wertarbyte.de
Fri Oct 8 12:33:48 UTC 2010


Dies schrieb Michael Tokarev (mjt at tls.msk.ru):

> Stefan Tomanek wrote:
> > This commit adds an configuration option to specify a script to be
> > executed before, during and after creating or configuring the pair of
> > veth devices.[...]
> 
> Why so many hooks?  Curious...

Please refer to the messages exhanged before, I addressed many of your points
there.

> There's apparently no reason to run a script "before"
> creating a netdev (pair).  Note that we don't even
> know which names will be used for the netdevs, at
> least in general case.

I know, but there might be a point in executing a point script before
network configuration in general. I cannot thin of an example right now,
but Debian has the same distinction for its network configuration.

> The "during" version makes no sense at all, in my
> opinion anyway, because we're syncronous, and there's
> no way to run something "during" the veth creation.
> So it actually becomes either "before" or "after"
> anyway.

It is "during" due to the fact that it is network type specific and
gets called inside the instanciate_* (veth in this case) function.
That is the only part where the host-facing interface name is known,
so calling a general hook afterwards is of no use.

> What makes sense -- again, in my opinion - is just
> one script that gets run after netdev creation and
> initialisation (when all the configured IP addresses
> were assigned and the like).

see above. Both is needed, a general hook that may be run after
configuration and a type specific hook that can make use of veth/phys/...
specific data.

> > -		if (lxc_create_network(&handler->conf->network)) {
> > +		if (lxc_create_network(handler)) {
> 
> The two changes appears to be unrelated to the script
> hook config, and makes somewhat non-obvious changes...

No, it is not unrelated. The patch passes the container name to
the hook scripts, which is made available to the functions by passing
the lxc_handle instance around.

Thanks for your feedback :-)




More information about the lxc-devel mailing list