[lxc-devel] [PATCH 1/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.
Christian Brauner
christianvanbrauner at gmail.com
Sun Sep 6 08:38:16 UTC 2015
Signed-off-by: Christian Brauner <christianvanbrauner at gmail.com>
100.0% src/lxc/
diff --git a/src/lxc/conf.h b/src/lxc/conf.h
index dc5328a..5aebd91 100644
--- a/src/lxc/conf.h
+++ b/src/lxc/conf.h
@@ -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
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index ca3b8d8..08608d7 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -108,6 +108,8 @@ 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 *key, const char *value,
+ struct lxc_conf *lxc_conf);
static struct lxc_config_t config[] = {
@@ -176,6 +178,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 +2493,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 +2764,14 @@ 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);
+
+ lxc_conf->ephemeral = v;
+
+ return 0;
+}
+
--
2.5.1
More information about the lxc-devel
mailing list