]> git.proxmox.com Git - mirror_lxc.git/commit
lxc: add clone hook.
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 14 May 2013 21:10:37 +0000 (16:10 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 16 May 2013 13:02:06 +0000 (08:02 -0500)
commit148e91f56799f03c868deca8dcad473983a1a2bf
tree852c34793996f02ca22d49c1848aa34372c6999e
parent9a93d99213da44b5ddf2f5295f6ef3a59d4f1fba
lxc: add clone hook.

Add a clone hook called from api_clone.  Pass arguments to it from
lxc_clone.c.

The clone update hook is called while the container's bdev is mounted.
Information about the container is passed in through environment
variables LXC_ROOTFS_PATH, LXC_NAME, The LXC_ROOTFS_MOUNT, and
LXC_CONFIG_FILE.

LXC_ROOTFS_MOUNT=/usr/lib/x86_64-linux-gnu/lxc
LXC_CONFIG_FILE=/var/lib/lxc/demo3/config
LXC_ROOTFS_PATH=/var/lib/lxc/demo3/rootfs
LXC_NAME=demo3

So from the hook, updates to the container should be made under
$LXC_ROOTFS_MOUNT/ .

The hook also receives command line arguments as follows:
First argument is container name, second is always 'lxc', third
is the hook name (always clone), then come the arguments which
were passed to lxc-clone.  I.e. when I did:

sudo lxc-clone demo2 demo3 -- hey there dude

the arguments passed in were "demo3 lxc clone hey there dude"

I personally would like to drop the first two arguments.  The
name is available as $LXC_NAME, and the section argument ('lxc')
is meaningless.  However, doing so risks invalidating existing
hooks.

Soon analogous create and destroy hooks will be added as well.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/conf.c
src/lxc/conf.h
src/lxc/confile.c
src/lxc/lxc_clone.c
src/lxc/lxccontainer.c
src/lxc/lxccontainer.h
src/lxc/start.c