Unverified Commit e96df99b by AustinReichert Committed by Christian Brauner

tools/lxc_start: removed internal logging

parent a9da03a7
...@@ -54,8 +54,6 @@ ...@@ -54,8 +54,6 @@
#define OPT_SHARE_IPC OPT_USAGE + 2 #define OPT_SHARE_IPC OPT_USAGE + 2
#define OPT_SHARE_UTS OPT_USAGE + 3 #define OPT_SHARE_UTS OPT_USAGE + 3
lxc_log_define(lxc_start_ui, lxc);
static struct lxc_list defines; static struct lxc_list defines;
static int ensure_path(char **confpath, const char *path) static int ensure_path(char **confpath, const char *path)
...@@ -67,7 +65,7 @@ static int ensure_path(char **confpath, const char *path) ...@@ -67,7 +65,7 @@ static int ensure_path(char **confpath, const char *path)
if (access(path, W_OK)) { if (access(path, W_OK)) {
fd = creat(path, 0600); fd = creat(path, 0600);
if (fd < 0 && errno != EEXIST) { if (fd < 0 && errno != EEXIST) {
SYSERROR("failed to create '%s'", path); fprintf(stderr, "failed to create '%s'\n", path);
goto err; goto err;
} }
if (fd >= 0) if (fd >= 0)
...@@ -76,7 +74,7 @@ static int ensure_path(char **confpath, const char *path) ...@@ -76,7 +74,7 @@ static int ensure_path(char **confpath, const char *path)
fullpath = realpath(path, NULL); fullpath = realpath(path, NULL);
if (!fullpath) { if (!fullpath) {
SYSERROR("failed to get the real path of '%s'", path); fprintf(stderr, "failed to get the real path of '%s'\n", path);
goto err; goto err;
} }
...@@ -95,19 +93,19 @@ static int pid_from_lxcname(const char *lxcname_or_pid, const char *lxcpath) { ...@@ -95,19 +93,19 @@ static int pid_from_lxcname(const char *lxcname_or_pid, const char *lxcpath) {
struct lxc_container *s; struct lxc_container *s;
s = lxc_container_new(lxcname_or_pid, lxcpath); s = lxc_container_new(lxcname_or_pid, lxcpath);
if (!s) { if (!s) {
SYSERROR("'%s' is not a valid pid nor a container name", lxcname_or_pid); fprintf(stderr, "'%s' is not a valid pid nor a container name\n", lxcname_or_pid);
return -1; return -1;
} }
if (!s->may_control(s)) { if (!s->may_control(s)) {
SYSERROR("Insufficient privileges to control container '%s'", s->name); fprintf(stderr, "Insufficient privileges to control container '%s'\n", s->name);
lxc_container_put(s); lxc_container_put(s);
return -1; return -1;
} }
pid = s->init_pid(s); pid = s->init_pid(s);
if (pid < 1) { if (pid < 1) {
SYSERROR("Is container '%s' running?", s->name); fprintf(stderr, "Is container '%s' running?\n", s->name);
lxc_container_put(s); lxc_container_put(s);
return -1; return -1;
} }
...@@ -115,7 +113,7 @@ static int pid_from_lxcname(const char *lxcname_or_pid, const char *lxcpath) { ...@@ -115,7 +113,7 @@ static int pid_from_lxcname(const char *lxcname_or_pid, const char *lxcpath) {
lxc_container_put(s); lxc_container_put(s);
} }
if (kill(pid, 0) < 0) { if (kill(pid, 0) < 0) {
SYSERROR("Can't send signal to pid %d", pid); fprintf(stderr, "Can't send signal to pid %d\n", pid);
return -1; return -1;
} }
...@@ -129,7 +127,7 @@ static int open_ns(int pid, const char *ns_proc_name) { ...@@ -129,7 +127,7 @@ static int open_ns(int pid, const char *ns_proc_name) {
fd = open(path, O_RDONLY); fd = open(path, O_RDONLY);
if (fd < 0) { if (fd < 0) {
SYSERROR("failed to open %s", path); fprintf(stderr, "failed to open %s\n", path);
return -1; return -1;
} }
return fd; return fd;
...@@ -252,18 +250,18 @@ int main(int argc, char *argv[]) ...@@ -252,18 +250,18 @@ int main(int argc, char *argv[])
rcfile = (char *)my_args.rcfile; rcfile = (char *)my_args.rcfile;
c = lxc_container_new(my_args.name, lxcpath); c = lxc_container_new(my_args.name, lxcpath);
if (!c) { if (!c) {
ERROR("Failed to create lxc_container"); fprintf(stderr, "Failed to create lxc_container\n");
exit(err); exit(err);
} }
c->clear_config(c); c->clear_config(c);
if (!c->load_config(c, rcfile)) { if (!c->load_config(c, rcfile)) {
ERROR("Failed to load rcfile"); fprintf(stderr, "Failed to load rcfile\n");
lxc_container_put(c); lxc_container_put(c);
exit(err); exit(err);
} }
c->configfile = strdup(my_args.rcfile); c->configfile = strdup(my_args.rcfile);
if (!c->configfile) { if (!c->configfile) {
ERROR("Out of memory setting new config filename"); fprintf(stderr, "Out of memory setting new config filename\n");
goto out; goto out;
} }
} else { } else {
...@@ -271,10 +269,9 @@ int main(int argc, char *argv[]) ...@@ -271,10 +269,9 @@ int main(int argc, char *argv[])
rc = asprintf(&rcfile, "%s/%s/config", lxcpath, my_args.name); rc = asprintf(&rcfile, "%s/%s/config", lxcpath, my_args.name);
if (rc == -1) { if (rc == -1) {
SYSERROR("failed to allocate memory"); fprintf(stderr, "failed to allocate memory\n");
exit(err); exit(err);
} }
INFO("using rcfile %s", rcfile);
/* container configuration does not exist */ /* container configuration does not exist */
if (access(rcfile, F_OK)) { if (access(rcfile, F_OK)) {
...@@ -283,7 +280,7 @@ int main(int argc, char *argv[]) ...@@ -283,7 +280,7 @@ int main(int argc, char *argv[])
} }
c = lxc_container_new(my_args.name, lxcpath); c = lxc_container_new(my_args.name, lxcpath);
if (!c) { if (!c) {
ERROR("Failed to create lxc_container"); fprintf(stderr, "Failed to create lxc_container\n");
exit(err); exit(err);
} }
} }
...@@ -300,7 +297,7 @@ int main(int argc, char *argv[]) ...@@ -300,7 +297,7 @@ int main(int argc, char *argv[])
} }
if (c->is_running(c)) { if (c->is_running(c)) {
ERROR("Container is already running."); fprintf(stderr, "Container is already running.\n");
err = EXIT_SUCCESS; err = EXIT_SUCCESS;
goto out; goto out;
} }
...@@ -316,13 +313,13 @@ int main(int argc, char *argv[]) ...@@ -316,13 +313,13 @@ int main(int argc, char *argv[])
goto out; goto out;
if (!rcfile && !strcmp("/sbin/init", args[0])) { if (!rcfile && !strcmp("/sbin/init", args[0])) {
ERROR("Executing '/sbin/init' with no configuration file may crash the host"); fprintf(stderr, "Executing '/sbin/init' with no configuration file may crash the host\n");
goto out; goto out;
} }
if (my_args.pidfile != NULL) { if (my_args.pidfile != NULL) {
if (ensure_path(&c->pidfile, my_args.pidfile) < 0) { if (ensure_path(&c->pidfile, my_args.pidfile) < 0) {
ERROR("failed to ensure pidfile '%s'", my_args.pidfile); fprintf(stderr, "failed to ensure pidfile '%s'\n", my_args.pidfile);
goto out; goto out;
} }
} }
...@@ -355,11 +352,11 @@ int main(int argc, char *argv[]) ...@@ -355,11 +352,11 @@ int main(int argc, char *argv[])
err = c->start(c, 0, args) ? EXIT_SUCCESS : EXIT_FAILURE; err = c->start(c, 0, args) ? EXIT_SUCCESS : EXIT_FAILURE;
if (err) { if (err) {
ERROR("The container failed to start."); fprintf(stderr, "The container failed to start.\n");
if (my_args.daemonize) if (my_args.daemonize)
ERROR("To get more details, run the container in foreground mode."); fprintf(stderr, "To get more details, run the container in foreground mode.\n");
ERROR("Additional information can be obtained by setting the " fprintf(stderr, "Additional information can be obtained by setting the "
"--logfile and --logpriority options."); "--logfile and --logpriority options.\n");
err = c->error_num; err = c->error_num;
lxc_container_put(c); lxc_container_put(c);
exit(err); exit(err);
......
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