]> git.proxmox.com Git - mirror_lxc.git/commit - src/lxc/conf.c
add support for nbd
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 15 May 2014 14:33:18 +0000 (14:33 +0000)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Fri, 16 May 2014 13:58:03 +0000 (09:58 -0400)
commit76a26f559ff2d9d47b2c886310e8e8c95af2c667
tree3c628325349edc275e41f42ccb89f6145c723d26
parent7e4ca1a21debdf0d04285446e4dbff5d8647b2d3
add support for nbd

backing stores supported by qemu-nbd can be attached to a nbd block
device using qemu-nbd.  This user-space process (pair) stays around for
the duration of the device attachment.  Obviously we want it to go away
when the container shuts down, but not before the filesystems have been
cleanly unmounted.

The device attachment is done from the task which will become the
container monitor before the container setup+init task is spawned.
That task starts in a new pid namespace to ensure that the qemu-nbd
process will be killed if need be.  It sets its parent death signal
to sighup, and, on receiving sighup, attempts to do a clean
qemu-device detach, then exits.  This should ensure that the
device is detached if the qemu monitor crashes or exits.

It may be worth adding a delay before the qemu-nbd is detached, but
my brief tests haven't seen any data corruption.

Only the parts required for running a nbd-backed container are
implemented here.  Create, destroy, and clone are not.  The first
use of this that I imagine is for people to use downloaded nbd-backed
images (like ubuntu cloud images, or anything previously used with
qemu).  I imagine people will want to create/clone/destroy out of
band using qemu-img, but if I'm wrong about that we can implement
the rest later.

Because attach_block_device() is done before the bdev is initialized,
and bdev_init needs to know the nbd index so that it can mount the
filesystem, we now need to pass the lxc_conf.

file_exists() is moved to utils.c so we can use it from bdev.c

The nbd attach/detach should lay the groundwork for trivial implementation
of qed and raw images.

changelog (may 12): fix idx check at detach
changelog (may 15): generalize qcow2 to nbd

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
src/lxc/bdev.c
src/lxc/bdev.h
src/lxc/conf.c
src/lxc/conf.h
src/lxc/lxccontainer.c
src/lxc/start.c
src/lxc/utils.c
src/lxc/utils.h