Unverified Commit 72615674 by Serge Hallyn Committed by GitHub

Merge pull request #1918 from brauner/2017-11-11/daemonized_execute

lxccontainer: enable daemonized execute
parents ed186661 be442598
...@@ -842,18 +842,6 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a ...@@ -842,18 +842,6 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
if (!handler) if (!handler)
return false; return false;
if (useinit) {
TRACE("calling \"lxc_execute\"");
ret = lxc_execute(c->name, argv, 1, handler, c->config_path,
daemonize);
c->error_num = ret;
if (ret != 0)
return false;
return true;
}
/* If no argv was passed in, use lxc.init_cmd if provided in the /* If no argv was passed in, use lxc.init_cmd if provided in the
* configuration * configuration
*/ */
...@@ -1033,7 +1021,10 @@ reboot: ...@@ -1033,7 +1021,10 @@ reboot:
goto on_error; goto on_error;
} }
ret = lxc_start(c->name, argv, handler, c->config_path, daemonize); if (useinit)
ret = lxc_execute(c->name, argv, 1, handler, c->config_path, daemonize);
else
ret = lxc_start(c->name, argv, handler, c->config_path, daemonize);
c->error_num = ret; c->error_num = ret;
if (conf->reboot == 1) { if (conf->reboot == 1) {
......
...@@ -49,6 +49,9 @@ static struct lxc_list defines; ...@@ -49,6 +49,9 @@ static struct lxc_list defines;
static int my_parser(struct lxc_arguments* args, int c, char* arg) static int my_parser(struct lxc_arguments* args, int c, char* arg)
{ {
switch (c) { switch (c) {
case 'd':
args->daemonize = 1;
break;
case 'f': case 'f':
args->rcfile = arg; args->rcfile = arg;
break; break;
...@@ -67,6 +70,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg) ...@@ -67,6 +70,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
} }
static const struct option my_longopts[] = { static const struct option my_longopts[] = {
{"daemon", no_argument, 0, 'd'},
{"rcfile", required_argument, 0, 'f'}, {"rcfile", required_argument, 0, 'f'},
{"define", required_argument, 0, 's'}, {"define", required_argument, 0, 's'},
{"uid", required_argument, 0, 'u'}, {"uid", required_argument, 0, 'u'},
...@@ -90,6 +94,7 @@ Options :\n\ ...@@ -90,6 +94,7 @@ Options :\n\
-g, --gid=GID Execute COMMAND with GID inside the container\n", -g, --gid=GID Execute COMMAND with GID inside the container\n",
.options = my_longopts, .options = my_longopts,
.parser = my_parser, .parser = my_parser,
.daemonize = 0,
}; };
static bool set_argv(struct lxc_conf *conf, struct lxc_arguments *args) static bool set_argv(struct lxc_conf *conf, struct lxc_arguments *args)
...@@ -180,7 +185,7 @@ int main(int argc, char *argv[]) ...@@ -180,7 +185,7 @@ int main(int argc, char *argv[])
if (my_args.gid) if (my_args.gid)
c->lxc_conf->init_gid = my_args.gid; c->lxc_conf->init_gid = my_args.gid;
c->daemonize = false; c->daemonize = my_args.daemonize == 1;
bret = c->start(c, 1, my_args.argv); bret = c->start(c, 1, my_args.argv);
ret = c->error_num; ret = c->error_num;
lxc_container_put(c); lxc_container_put(c);
......
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