On 13:57 Wed 28 Apr , Guido Trotter wrote:
> On Wed, Apr 28, 2010 at 11:15 AM, Guido Trotter <[email protected]> wrote:
> > On Mon, Apr 26, 2010 at 1:20 PM, Apollon Oikonomopoulos
> > <[email protected]> wrote:
> > I'm wondering if both up and down scripts should live in the new
> > runtime files dir.
> >
> > Also, I had another thought: is there an option to ship a static (bash
> > or python) ganeti-kvm-ifup and ganeti-kvm-ifdown script, and let it
> > read the instance configuration from somewhere on disk? This would
> > simplify everything a lot, wouldn't it?
>
> I just checked and apparently newer KVM passes environment variables
> it gets back to interface scripts (older versions didn't, IIRC).
Indeed, it does fork() + execv(), so the scripts inherit the
environment. I think it's rather possible that older versions did it as
well.
> So if that's ok for you we could create a
> CONF_DIR/instance_interface.sh file with just the variable
> assignments, pass the instance name as an environment variable to kvm,
> and then just call /usr/lib/ganeti/ganeti-kvm-ifdown (or just
> kvm-ifdown) which would source that script, and then call the site
> script in /etc (or in the future even do a run-parts). Would that work
> for you? This simplifies everything greatly.
There is one problem with this: ganeti does not know the tap interface
name (only kvm knows this) and kvm does not pass the information of
which NIC it is actually configuring (partly because KVM's network model
does not necessarily map NICs to tap devices in a 1-1 fashion, although
ganeti forces this with commit 760570a8).
Thus, a single ganeti-kvm-if{up,down}, even with the full environment,
wouldn't be able to use NIC_IP or NIC_LINK if it wanted to. Unless kvm
switches to execve() and passes more information (e.g. vlan index), it
seems that the one-script-per-tap interface is the only way to go. There
is one possible exception to this, using pre-defined, unique tap
interface names on the KVM command line, so that ganeti knows which tap
device corresponds to which NIC.
Thanks,
Apollon