[lxc-devel] [PATCH v1] Add lxc-copy executable

Christian Brauner christianvanbrauner at gmail.com
Wed Nov 4 14:59:06 UTC 2015


Changes in comparison to first implementation:

(1) Instead of using a custom function to generate random names for ephemeral
    container we use mkdtemp(). This will be safer and the code considerably
    easier.
(2) Make the whole code easily extendable by using a design centered around a
    struct and an enum. The current design will allow us to add further mount
    types should we want to:
        enum mnttype {
        	LXC_MNT_BIND,
        	LXC_MNT_AUFS,
        	LXC_MNT_OVL,
        };

        struct mnts {
        	enum mnttype type;
        	char *src;
        	char *dest;
        	char *options;
        	char *upper;
        	char *workdir;
        	char *lower;
        };

   (E.g. lowerdir is currently not used but we could in the future allow users
    to specify multiple lowerdirs on the command line. All we would have to do
    is to extend the corresponding parse function parse_ovl_mnt().)

(3) We use getsubopt() to parse the custom mounts user can specify with the -m
    flag and the keys {aufs,bind,overlay}. This will avoid redundancy because
    users do not have to specify multiple -m flags but can rather just do -m
    bind=/a:/b,overlay/c:/d etc. Furthermore, it will allow us to add further
    keys rather easily.

(4) There is a branch lxccopy on github for easier testing:

        https://github.com/brauner/lxc/tree/lxccopy

Serge, I wonder how many bugs you will find. :)

Christian Brauner (1):
  Add lxc-copy executable

 src/lxc/Makefile.am |   2 +
 src/lxc/arguments.h |   2 +
 src/lxc/lxc_copy.c  | 744 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 748 insertions(+)
 create mode 100644 src/lxc/lxc_copy.c

-- 
2.6.2



More information about the lxc-devel mailing list