On 05/25/2012 04:17 AM, Matthijs Kooijman wrote:
> Hi Stéphane,
> 
>>  - stop: Is run after the container died
>> [...]
>> Potential other hooks include pre-start and post-stop
> What would be the difference between stop and post-stop, if stop also
> runs _after_ the container died?
> 
> Gr.
> 
> Matthijs

It'd be run after the umount has been done.

But that got me to go and read the OpenVZ definition of these and made
me catch a "small" detail I had missed.

The start and stop hooks in OpenVZ are actually run in the container's
namespaces.

Basically the timeline would be:
 - HOOK: pre-start (host namespace)
 - LXC: mount rootfs and fstab entries
 - HOOK: mount (host namespace)
 - LXC: spawn init
 - HOOK: start (container namespace)
 - USER: do whatever they want in the container
 - LXC: stops the container
 - HOOK: stop (container namespace)
 - LXC: kill the container
 - HOOK: umount (host namespace)
 - LXC: umount rootfs and fstab entries
 - HOOK: post-stop (host namespace)

Based on OpenVZ documentation, if we aim at implementing something
similar, then:
 - "start" would be run inside the container (but script lives outside
of it) and called right before init is spawned.
 - "stop" would be run inside the container (but script lives outside of
it) and called right after init dies.

I must admit never having used these two and I'm a bit unsure whether
they are really that useful and whether we can even implement them with
the current state of things.


Something else I didn't mention in my original post is the behavior on
exit failure for the hooks. OpenVZ typically treats any non-zero return
code as a failure and tries to kill the container but without calling
any additional hook.
For example, a failure in the "start" hook will cause the container to
be shutdown and unmounted but without calling the stop, umount or
post-stop hooks.

(I'm mostly looking at
http://download.openvz.org/doc/OpenVZ-Users-Guide.pdf in the "OpenVZ
Action Scripts" section)


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel

Reply via email to