</para>
<para>
If no command is specified, <command>lxc-start</command> will
- use the default
+ use the command defined in lxc.init_cmd or if not set, the default
<command>"/sbin/init"</command> command to run a system
container.
</para>
</variablelist>
</refsect2>
+ <refsect2>
+ <title>Init command</title>
+ <para>
+ Sets the command to use as the init system for the containers.
+
+ This option is ignored when using lxc-execute.
+
+ Defaults to: /sbin/init
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ <option>lxc.init_cmd</option>
+ </term>
+ <listitem>
+ <para>
+ Absolute path from container rootfs to the binary to use as init.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect2>
+
<refsect2>
<title>Network</title>
<para>
command into the container.
The pid of the first process is 1. If no command is
specified <command>lxc-start</command> will
- run <filename>/sbin/init</filename>.
+ run the command defined in lxc.init_cmd or if not set,
+ <filename>/sbin/init</filename> .
</para>
<para>
free(conf->fstab);
if (conf->rcfile)
free(conf->rcfile);
+ if (conf->init_cmd)
+ free(conf->init_cmd);
free(conf->unexpanded_config);
lxc_clear_config_network(conf);
if (conf->lsm_aa_profile)
/* text representation of the config file */
char *unexpanded_config;
size_t unexpanded_len, unexpanded_alloced;
+
+ /* init command */
+ char *init_cmd;
};
int run_lxc_hooks(const char *name, char *hook, struct lxc_conf *conf,
static int config_start(const char *, const char *, struct lxc_conf *);
static int config_group(const char *, const char *, struct lxc_conf *);
static int config_environment(const char *, const char *, struct lxc_conf *);
+static int config_init_cmd(const char *, const char *, struct lxc_conf *);
static struct lxc_config_t config[] = {
{ "lxc.start.order", config_start },
{ "lxc.group", config_group },
{ "lxc.environment", config_environment },
+ { "lxc.init_cmd", config_init_cmd },
};
struct signame {
return config_path_item(&lxc_conf->seccomp, value);
}
+static int config_init_cmd(const char *key, const char *value,
+ struct lxc_conf *lxc_conf)
+{
+ return config_path_item(&lxc_conf->init_cmd, value);
+}
+
static int config_hook(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
v = c->seccomp;
else if (strcmp(key, "lxc.environment") == 0)
return lxc_get_item_environment(c, retv, inlen);
+ else if (strcmp(key, "lxc.init_cmd") == 0)
+ v = c->init_cmd;
else return -1;
if (!v)
struct lxc_container **containers = NULL;
struct lxc_list **c_groups_lists = NULL;
struct lxc_list *cmd_group;
- char *const default_start_args[] = {
- "/sbin/init",
- NULL,
- };
if (lxc_arguments_parse(&my_args, argc, argv))
return 1;
printf("%s %d\n", c->name,
get_config_integer(c, "lxc.start.delay"));
else {
- if (!c->start(c, 0, default_start_args))
+ if (!c->start(c, 0, NULL))
fprintf(stderr, "Error starting container: %s\n", c->name);
else
sleep(get_config_integer(c, "lxc.start.delay"));
if (my_args.close_all_fds)
c->want_close_all_fds(c, true);
- err = c->start(c, 0, args) ? 0 : 1;
+ if (args == default_args)
+ err = c->start(c, 0, NULL) ? 0 : 1;
+ else
+ err = c->start(c, 0, args) ? 0 : 1;
if (err) {
ERROR("The container failed to start.");
"/sbin/init",
NULL,
};
+ char *init_cmd[2];
/* container exists */
if (!c)
return ret == 0 ? true : false;
}
- if (!argv)
- argv = default_args;
+ if (!argv) {
+ if (conf->init_cmd) {
+ init_cmd[0] = conf->init_cmd;
+ init_cmd[1] = NULL;
+ argv = init_cmd;
+ }
+ else
+ argv = default_args;
+ }
/*
* say, I'm not sure - what locks do we want here? Any?