These commits enable a container to be destroyed on shutdown by setting lxc.ephemeral = 1 in its configuration file. This will allow us a consistent implementation of lxc-copy = lxc-clone + lxc-start-ephemeral without having to resort to hacks.
Small changes: lxc_delete_string_in_array() has beed added to utils.c. It replaces the manual method for deleting a container entry in lxc_snapshots files in mod_rdep() in lxccontainer.c. static do_bdev_destroy() has been moved to bdev.c and bdev.h and made public because it will be reused in start.c. The "shutdown-handler" lxc_fini() has been modified to call the new static function lxc_destroy_container_on_signal() to destroy containers which have lxc.ephemeral = 1 set in their config file. Currently only overlayfs and aufs backed containers can be destroyed in this way because this is so far the only case we care about (lxc-start-ephemeral part of lxc-copy) but the function works for all bdev types supported by lxc. These commits are also present as a PR on github. Christian Brauner (6): Add lxc.ephemeral lxc.ephemeral indicates whether a container will be destroyed on shutdown Any integer value > 0 can be used to indicate that a container is ephemeral. Delete string from array Add function to delete a string from a non-null terminated buffer Remove container entry from lxc_snapshots file Use new helper function lxc_delete_string_in_array() from utils.c Add bdev_destroy() to bdev.c and bdev.h static do_bdev_destroy() in lxccontainer.c becomes public bdev_destroy() Destroy bdevs using new bdev_destroy() from bdev.h Enable lxc_fini() to destroy container on shutdown This works for any bdev-type but is only used for overlayfs and aufs now src/lxc/bdev.c | 18 +++++++++++++ src/lxc/bdev.h | 1 + src/lxc/conf.h | 3 +++ src/lxc/confile.c | 16 ++++++++++++ src/lxc/lxccontainer.c | 35 ++++++------------------- src/lxc/start.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/lxc/utils.c | 14 ++++++++++ src/lxc/utils.h | 3 +++ 8 files changed, 133 insertions(+), 27 deletions(-) -- 2.5.1 _______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel