Commit 46926165 by Marek Majkowski

Refactoring - make the option parsing code generic

parent f8059880
......@@ -54,8 +54,7 @@ struct lxc_arguments {
int lxcpath_additional;
/* for lxc-start */
const char *share_net;
const char *share_ipc;
const char *share_ns[32]; // size must be greater than LXC_NS_MAX
/* for lxc-checkpoint/restart */
const char *statefile;
......
......@@ -151,8 +151,8 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
case 'C': args->close_all_fds = 1; break;
case 's': return lxc_config_define_add(&defines, arg);
case 'p': args->pidfile = arg; break;
case OPT_SHARE_NET: args->share_net = arg; break;
case OPT_SHARE_IPC: args->share_ipc = arg; break;
case OPT_SHARE_NET: args->share_ns[LXC_NS_NET] = arg; break;
case OPT_SHARE_IPC: args->share_ns[LXC_NS_IPC] = arg; break;
}
return 0;
}
......@@ -306,26 +306,19 @@ int main(int argc, char *argv[])
}
}
if (my_args.share_net != NULL) {
int pid = pid_from_lxcname(my_args.share_net, lxcpath);
if (pid < 1)
goto out;
int fd = open_ns(pid, "net");
if (fd < 0)
goto out;
conf->inherit_ns_fd[LXC_NS_NET] = fd;
}
int i;
for (i = 0; i < LXC_NS_MAX; i++) {
if (my_args.share_ns[i] == NULL)
continue;
if (my_args.share_ipc != NULL) {
int pid = pid_from_lxcname(my_args.share_ipc, lxcpath);
int pid = pid_from_lxcname(my_args.share_ns[i], lxcpath);
if (pid < 1)
goto out;
int fd = open_ns(pid, "ipc");
int fd = open_ns(pid, ns_info[i].proc_name);
if (fd < 0)
goto out;
conf->inherit_ns_fd[LXC_NS_IPC] = fd;
conf->inherit_ns_fd[i] = fd;
}
if (my_args.daemonize) {
......
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