Commit 8796becf by Christian Brauner Committed by Stéphane Graber

Add lxc.ephemeral lxc.ephemeral indicates whether a container will be destroyed…

Add lxc.ephemeral lxc.ephemeral indicates whether a container will be destroyed on shutdown Can be 0 for non-ephemeral and 1 for ephemeral. Signed-off-by: 's avatarChristian Brauner <christianvanbrauner@gmail.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 186bef00
...@@ -370,6 +370,9 @@ struct lxc_conf { ...@@ -370,6 +370,9 @@ struct lxc_conf {
* should run under when using lxc-execute */ * should run under when using lxc-execute */
uid_t init_uid; uid_t init_uid;
gid_t init_gid; gid_t init_gid;
/* indicator if the container will be destroyed on shutdown */
int ephemeral;
}; };
#ifdef HAVE_TLS #ifdef HAVE_TLS
......
...@@ -108,6 +108,7 @@ static int config_environment(const char *, const char *, struct lxc_conf *); ...@@ -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_cmd(const char *, const char *, struct lxc_conf *);
static int config_init_uid(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_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[] = { static struct lxc_config_t config[] = {
...@@ -176,6 +177,7 @@ static struct lxc_config_t config[] = { ...@@ -176,6 +177,7 @@ static struct lxc_config_t config[] = {
{ "lxc.init_cmd", config_init_cmd }, { "lxc.init_cmd", config_init_cmd },
{ "lxc.init_uid", config_init_uid }, { "lxc.init_uid", config_init_uid },
{ "lxc.init_gid", config_init_gid }, { "lxc.init_gid", config_init_gid },
{ "lxc.ephemeral", config_ephemeral },
}; };
struct signame { struct signame {
...@@ -2490,6 +2492,8 @@ int lxc_get_config_item(struct lxc_conf *c, const char *key, char *retv, ...@@ -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); return lxc_get_conf_int(c, retv, inlen, c->init_uid);
else if (strcmp(key, "lxc.init_gid") == 0) else if (strcmp(key, "lxc.init_gid") == 0)
return lxc_get_conf_int(c, retv, inlen, c->init_gid); 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; else return -1;
if (!v) if (!v)
...@@ -2759,3 +2763,19 @@ bool network_new_hwaddrs(struct lxc_conf *conf) ...@@ -2759,3 +2763,19 @@ bool network_new_hwaddrs(struct lxc_conf *conf)
} }
return true; 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment