lxc_attach: Use clone() instead of second fork()

Because of an assertion in glibc's fork() wrapper that parent pid and
pid of child should never be the same, one should avoid fork() after
attaching to a PID namespace, since the pid inside the namespace may
coincide with the pid of the parent outside the namespace, thus hitting
the aforementioned assertion.

This patch just changes the code in the most simple manner to use
clone() instead of fork(). Since clone() requires a function to be
called instead of returning 0, we move the code of the child into a
function child_main.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
lxc_wait should start monitord

If lxc_wait is called before the container has started the socket will not
yet have been created and lxc_wait's connect to it will fail. Starting the
daemon will create the socket for lxc_wait to connect to.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
add zfs support to lxc-create and lxc-destroy

This is based on patch from Papp Tamas (thanks).  It also does some
reorganizing of lxc-create to commonize some of the backingstore handling.

I played with it using:

	sudo lvcreate -L 100G -n zfs vg0
	sudo zpool create lxc /dev/vg0/zfs
	sudo lxc-create -B zfs --zfsroot lxc -t ubuntu -n dir2

or you could

	qemu-img create zfs.img 100G
	sudo qemu-nbd -c /dev/nbd0 zfs.img
	sudo zpool create lxc /dev/nbd0
	sudo lxc-create -B zfs --zfsroot lxc -t ubuntu -n dir2

I'll write the bdev.c handler and hook up lxc-clone next.

This also fixses a bug in the sed expression to extract the rootfs from
container config, which prepended an extra '/' to the rootdev.  (That
caused the zfs list entry not to match at destroy)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Cc: Papp Tamas <tompos@martos.bme.hu>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
lxcapi: Add new get_ips() call

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>