[lxc-devel] startup scripts for lxc containers?

Daniel Lezcano daniel.lezcano at free.fr
Fri Jan 15 17:33:23 UTC 2010


Dietmar Maurer wrote:
>> Dietmar Maurer wrote:
>>     
>>>> Aah, yes, yes. shutdown a container is a pain, I agree. It's a
>>>>         
>> missing
>>     
>>>> kernel functionality, I several times reported this problem to the
>>>> containers@ mailing list but I had no answer.
>>>>
>>>> Any volunteer to help to write a kernel patch ?
>>>>         
>>> I thought my init-logger patch solves those problems - why do you
>>> want a kernel based solution instead?
>>>       
>> How the init-logger handles the shutdown ?
>>     
>
> You can execute command inside the container. So you just
> need to exec halt/shutdown inside the container?
>   
The problem we are facing is to detect when a process did a sys_reboot 
in order to kill the init process.
Otherwise the container is shutdown but the pid 1 still lives and the 
container never exits.

If I am not wrong the shutdown command sends a command to the init 
process to switch to run level 0 making the different services to do the 
right things. When this level is reached the shutdown process calls 
sys_reboot(SHUTDOWN) (which actually fails in a container because the 
CAP_SYS_REBOOT is dropped).

A work around would be to add in the latest shutdown script a write, for 
example to a fifo, which is read from the parent's init process in order 
to detect a shutdown. But we can not do the difference between a reboot 
or a shutdown, that looks like a trick more than a real solution...

For this reason, I proposed to hack the sys_reboot syscall and do 
"something", I don't know what exactly (maybe sending a signal to the 
init's parent with the relevant information).






More information about the lxc-devel mailing list