[lxc-devel] startup scripts for lxc containers?

Michael H. Warfield mhw at WittsEnd.com
Fri Jan 15 20:54:52 UTC 2010


On Fri, 2010-01-15 at 18:40 +0100, Dietmar Maurer wrote: 
> > > 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.
> 
> Oh, I thought init calls exit after it killed all children.

Apparently not.  I've got CentOS 5 and Fedora 11 containers and they all
hang there with init running at the end.  A kill or lxc-stop is required
to finish the job. 

> > 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).

> well, i will test that (and take a look at the init/upstart code).

That's probably my A number 1 problem right now.  If someone reboots a
container, it's dead until someone intervenes on the host system.

> > 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).

Yeah, obviously we would need to take appropriate action whether it's a
halt or a reboot.  Just having init exit would not tell the parent
process if it was suppose to "restart" that VM or not.

> OK

> - Dietmar

Mike
-- 
Michael H. Warfield (AI4NB) | (770) 985-6132 |  mhw at WittsEnd.com
   /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
   NIC whois: MHW9          | An optimist believes we live in the best of all
 PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20100115/89931cf5/attachment.pgp>


More information about the lxc-devel mailing list