</refsect2>
<refsect2>
- <title> Logging</title>
+ <title>Logging</title>
<para>
Logging can be configured on a per-container basis. By default,
depending upon how the lxc package was compiled, container startup
</variablelist>
</refsect2>
+ <refsect2>
+ <title>Autostart</title>
+ <para>
+ The autostart options support marking which containers should be
+ auto-started and in what order. These options may be used by LXC tools
+ directly or by external tooling provided by the distributions.
+ </para>
+
+ <variablelist>
+ <varlistentry>
+ <term>
+ <option>lxc.start.auto</option>
+ </term>
+ <listitem>
+ <para>
+ Whether the container should be auto-started.
+ Valid values are 0 (off) and 1 (on).
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <option>lxc.start.delay</option>
+ </term>
+ <listitem>
+ <para>
+ How long to wait (in seconds) after the container is
+ started before starting the next one.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <option>lxc.start.order</option>
+ </term>
+ <listitem>
+ <para>
+ An integer used to sort the containers when auto-starting
+ a series of containers at once.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <option>lxc.group</option>
+ </term>
+ <listitem>
+ <para>
+ A multi-value key (can be used multiple times) to put the
+ container in a container group. Those groups can then be
+ used (amongst other things) to start a series of related
+ containers.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect2>
</refsect1>
<refsect1>
static int config_network_nic(const char *, const char *, struct lxc_conf *);
static int config_autodev(const char *, const char *, struct lxc_conf *);
static int config_stopsignal(const char *, const char *, struct lxc_conf *);
+static int config_start(const char *, const char *, struct lxc_conf *);
+static int config_group(const char *, const char *, struct lxc_conf *);
static struct lxc_config_t config[] = {
{ "lxc.include", config_includefile },
{ "lxc.autodev", config_autodev },
{ "lxc.stopsignal", config_stopsignal },
+ { "lxc.start.auto", config_start },
+ { "lxc.start.delay", config_start },
+ { "lxc.start.order", config_start },
+ { "lxc.group", config_group },
};
struct signame {
return 0;
}
+static int config_start(const char *key, const char *value,
+ struct lxc_conf *lxc_conf)
+{
+ if(strcmp(key, "lxc.start.auto") == 0) {
+ lxc_conf->start_auto = atoi(value);
+ return 0;
+ }
+ else if (strcmp(key, "lxc.start.delay") == 0) {
+ lxc_conf->start_delay = atoi(value);
+ return 0;
+ }
+ else if (strcmp(key, "lxc.start.order") == 0) {
+ lxc_conf->start_order = atoi(value);
+ return 0;
+ }
+ SYSERROR("Unknown key: %s", key);
+ return -1;
+}
+
+static int config_group(const char *key, const char *value,
+ struct lxc_conf *lxc_conf)
+{
+ char *groups, *groupptr, *sptr, *token;
+ struct lxc_list *grouplist;
+ int ret = -1;
+
+ if (!strlen(value))
+ return lxc_clear_groups(lxc_conf);
+
+ groups = strdup(value);
+ if (!groups) {
+ SYSERROR("failed to dup '%s'", value);
+ return -1;
+ }
+
+ /* in case several groups are specified in a single line
+ * split these groups in a single element for the list */
+ for (groupptr = groups;;groupptr = NULL) {
+ token = strtok_r(groupptr, " \t", &sptr);
+ if (!token) {
+ ret = 0;
+ break;
+ }
+
+ grouplist = malloc(sizeof(*grouplist));
+ if (!grouplist) {
+ SYSERROR("failed to allocate groups list");
+ break;
+ }
+
+ grouplist->elem = strdup(token);
+ if (!grouplist->elem) {
+ SYSERROR("failed to dup '%s'", token);
+ free(grouplist);
+ break;
+ }
+
+ lxc_list_add_tail(&lxc_conf->groups, grouplist);
+ }
+
+ free(groups);
+
+ return ret;
+}
+
static int config_tty(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
return fulllen;
}
+static int lxc_get_item_groups(struct lxc_conf *c, char *retv, int inlen)
+{
+ int len, fulllen = 0;
+ struct lxc_list *it;
+
+ if (!retv)
+ inlen = 0;
+ else
+ memset(retv, 0, inlen);
+
+ lxc_list_for_each(it, &c->groups) {
+ strprint(retv, inlen, "%s\n", (char *)it->elem);
+ }
+ return fulllen;
+}
+
static int lxc_get_item_cap_drop(struct lxc_conf *c, char *retv, int inlen)
{
int len, fulllen = 0;
return lxc_get_item_network(c, retv, inlen);
else if (strncmp(key, "lxc.network.", 12) == 0)
return lxc_get_item_nic(c, retv, inlen, key + 12);
+ else if (strcmp(key, "lxc.start.auto") == 0)
+ return lxc_get_conf_int(c, retv, inlen, c->start_auto);
+ else if (strcmp(key, "lxc.start.delay") == 0)
+ return lxc_get_conf_int(c, retv, inlen, c->start_delay);
+ else if (strcmp(key, "lxc.start.order") == 0)
+ return lxc_get_conf_int(c, retv, inlen, c->start_order);
+ else if (strcmp(key, "lxc.group") == 0)
+ return lxc_get_item_groups(c, retv, inlen);
else return -1;
if (!v)
return lxc_clear_mount_entries(c);
else if (strncmp(key, "lxc.hook", 8) == 0)
return lxc_clear_hooks(c, key);
+ else if (strncmp(key, "lxc.group", 9) == 0)
+ return lxc_clear_groups(c);
return -1;
}