]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Add lxc.ephemeral lxc.ephemeral indicates whether a container will be destroyed on...
authorChristian Brauner <christianvanbrauner@gmail.com>
Tue, 8 Sep 2015 20:37:13 +0000 (22:37 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 21 Sep 2015 15:40:02 +0000 (11:40 -0400)
Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/conf.h
src/lxc/confile.c

index dc5328a3fed588cb5f7c23c3e4f756c1211beb7b..5aebd9167957639293204996b943eaedba9fe364 100644 (file)
@@ -370,6 +370,9 @@ struct lxc_conf {
         * should run under when using lxc-execute */
        uid_t init_uid;
        gid_t init_gid;
+
+       /* indicator if the container will be destroyed on shutdown */
+       int ephemeral;
 };
 
 #ifdef HAVE_TLS
index ca3b8d85a1247c6e21502ebc3c3704a509e481ec..5f8540e300356a016f5caad9d187c08017940ad8 100644 (file)
@@ -108,6 +108,7 @@ static int config_environment(const char *, const char *, struct lxc_conf *);
 static int config_init_cmd(const char *, const char *, struct lxc_conf *);
 static int config_init_uid(const char *, const char *, struct lxc_conf *);
 static int config_init_gid(const char *, const char *, struct lxc_conf *);
+static int config_ephemeral(const char *, const char *, struct lxc_conf *);
 
 static struct lxc_config_t config[] = {
 
@@ -176,6 +177,7 @@ static struct lxc_config_t config[] = {
        { "lxc.init_cmd",             config_init_cmd             },
        { "lxc.init_uid",             config_init_uid             },
        { "lxc.init_gid",             config_init_gid             },
+       { "lxc.ephemeral",            config_ephemeral            },
 };
 
 struct signame {
@@ -2490,6 +2492,8 @@ int lxc_get_config_item(struct lxc_conf *c, const char *key, char *retv,
                return lxc_get_conf_int(c, retv, inlen, c->init_uid);
        else if (strcmp(key, "lxc.init_gid") == 0)
                return lxc_get_conf_int(c, retv, inlen, c->init_gid);
+       else if (strcmp(key, "lxc.ephemeral") == 0)
+               return lxc_get_conf_int(c, retv, inlen, c->ephemeral);
        else return -1;
 
        if (!v)
@@ -2759,3 +2763,19 @@ bool network_new_hwaddrs(struct lxc_conf *conf)
        }
        return true;
 }
+
+static int config_ephemeral(const char *key, const char *value,
+                           struct lxc_conf *lxc_conf)
+{
+       int v = atoi(value);
+
+       if (v != 0 && v != 1) {
+               ERROR("Wrong value for lxc.ephemeral. Can only be set to 0 or 1");
+               return -1;
+       } else {
+               lxc_conf->ephemeral = v;
+       }
+
+       return 0;
+}
+