implement backend drivers and container clone API (v2)

1. commonize waitpid users to use a single helper.  We frequently want
to run something in a clean namespace, or fork off a script.  This
lets us keep the function doing fork:(1)exec(2)waitpid simpler.

2. start a blockdev backend implementation.  This will be used for
mounting, copying, and snapshotting container filesystems.

3. implement btrfs, lvm, directory, and overlayfs backends.  (Note btrfs
copy clones probably should not be supported at all, so I should either
remove that, or else I need to turn the resulting rootfs into a new
subvolume, which I'm not doing now).

4. For overlayfs, support a new lxc.rootfs format of
'bdevtype:<extra>'.  This means you can now use overlayfs-based
containers without using lxc-start-ephemeral, by using
lxc.rootfs = overlayfs:/readonly-dir:writeable-dir

5. add a set of simple clone testcases

6. Write a new lxc_clone.c.  This is just for testing, and probably
temporary until we write a python version, and if we stick with c we
need to at least make it conform to the other lxc- tools.  No
documentation but you can use it as

	lxc-clone a b # does a copy clone of a to b
	lxc-clone -s a b # does a snapshot clone of a to b
	lxc-clone -o a b # creates an overlayfs clone of a to b - a should be directory backed

Other than the -o (overlayfs) option, it always creates the clone with
the same backing store as the original, and does not specify a custom
fs size.  Note there are several options in the clone api not being
exercised.  But I'm using this on my own box right now as it turns out
very useful.

It would be nice if there were a btrfs development library
package with simple functions to do this stuff, but AFAICS
there is not, so I've copied some struct definitions and
ioctl value defines from the btfs-tools source into bdev.c

The testcase and lxc-clone.c show how to use this.  There are two types
of clones: copy and snapshot.  Right now you create a copy clone from
lvm->lvm, btrfs->btrfs, and dir->dir, a snapshot clone from lvm->lvm,
dir->overlayfs and overlayfs->overlayfs.  Note that this means you can
now use the api to do incremental image development, as is done manually
by docker:

	// create original container, directory based
	c1 = lxc_container_new("c1", NULL);
	c1->save_config(c1, NULL);
	c1->createl(c1, "ubuntu", NULL);
	c1->load_config(c1, NULL);

	// start it, log in and make some changes
	c1->want_daemonize(c1);
	c1->startl(c1, 0, NULL, NULL);
	// log in and do stuff, shut it down

	// create overlayfs clone
	c2 = c1->clone(c1, "c2", NULL, LXC_CLONE_SNAPSHOT, "overlayfs",
		NULL, 0);
	lxc_container_put(c1);
	// start it, log in make some changes
	c2->want_daemonize(c2);
	c2->startl(c2, 0, NULL, NULL);
	// log in and do stuff, shut it down

	c3 = c2->clone(c2, "c3", NULL, LXC_CLONE_SNAPSHOT, "overlayfs",
		NULL, 0);
	lxc_container_put(c2);
	// etc

c2 mounts c1's rootfs overlayed with /var/lib/lxc/c2/delta0.  When c3 is
created, c2's delta0 is rsync'ed to c3's, and c3 mounts c1's rootfs
overlayed with its rsynced /var/lib/lxc/c3/delta0.

Once Stéphane implements :) python bindings, lxc-clone can be switched
to python using this implementation.

Still to do (there's more, but off top of my head):

1. support zfs, aufs
2. have clone handle other mount entries (right now it only clones
the rootfs)
3. python, lua, and go bindings (not me :)
4. re-write lxc-clone
5. add lxc.numsnapshots - in the above case, c1 should not be
destroyable until all its clones are gone
6. Move bdev to its own directory (src/bdev) with one backing store
per file
7. Consider using fewer execs (for lvcreate etc)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>