[lxc-devel] startup scripts for lxc containers?
Michael Holzt
lxc at my.fqdn.org
Sat Jan 16 00:03:11 UTC 2010
> Oh, I thought init calls exit after it killed all children.
No it does not.
I was thinking about the problem the other day as well. I think some of it
is already covered by the work of Dietmar. I will describe my ideas in full
anyway:
1. lxc-start opens a pipe.
2. As the first process in the container a daemon e.g. lxc-ctld is launched
which becomes pid 1. It will fork so that it will become pid 2 also and
then in pid 1 a exec to the init binary is done so that init will be pid
1 as it expects. This process keeps one end of the pipe.
3. Now how to detect shutdown or reboot, i had two ideas.
One is to modify /etc/init.d/halt and /etc/init.d/reboot to send a
signal to lxc-ctld. Two different signals, one for halt, one for
reboot.
Other idea is to just have init-ctl sit there. When it receives sigterm
- emitted by init upon shutdown/reboot - it will determine runlevel
(0 or 6) and thus know if it is reboot or halt.
lxc-ctld will signal this to lxc-start through the pipe so that
lxc-start now knows what action to take.
lxc-ctld will not exit on sigterm but wait to be killed through sigkill
by init.
4. lxc-start which knows that shutdown or reboot is in progress until
lxc-ctld process is no longer in the process table and then kills
the init in the container.
Problems: We know the "outer" pid of the init in the container but not
of lxc-ctld. Maybe change argv[0] to make it findable.
Comments?
Regards
Michael
--
It's an insane world, but i'm proud to be a part of it. -- Bill Hicks
More information about the lxc-devel
mailing list