Commit 7bc5a80b by LiFeng

Create console when the rootfs is NULL

Signed-off-by: 's avatarLiFeng <lifeng68@huawei.com>
parent dc4f8fb1
...@@ -747,12 +747,6 @@ int lxc_console_create(struct lxc_conf *conf) ...@@ -747,12 +747,6 @@ int lxc_console_create(struct lxc_conf *conf)
int ret; int ret;
struct lxc_console *console = &conf->console; struct lxc_console *console = &conf->console;
if (!conf->rootfs.path) {
INFO("Container does not have a rootfs. The console will be "
"shared with the host");
return 0;
}
if (console->path && !strcmp(console->path, "none")) { if (console->path && !strcmp(console->path, "none")) {
INFO("No console was requested"); INFO("No console was requested");
return 0; return 0;
......
...@@ -472,7 +472,7 @@ int lxc_set_state(const char *name, struct lxc_handler *handler, ...@@ -472,7 +472,7 @@ int lxc_set_state(const char *name, struct lxc_handler *handler,
int lxc_poll(const char *name, struct lxc_handler *handler) int lxc_poll(const char *name, struct lxc_handler *handler)
{ {
int ret; int ret;
bool has_console = (handler->conf->rootfs.path != NULL); struct lxc_console *console = &handler->conf->console;
struct lxc_epoll_descr descr, descr_console; struct lxc_epoll_descr descr, descr_console;
ret = lxc_mainloop_open(&descr); ret = lxc_mainloop_open(&descr);
...@@ -481,12 +481,10 @@ int lxc_poll(const char *name, struct lxc_handler *handler) ...@@ -481,12 +481,10 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
goto out_sigfd; goto out_sigfd;
} }
if (has_console) { ret = lxc_mainloop_open(&descr_console);
ret = lxc_mainloop_open(&descr_console); if (ret < 0) {
if (ret < 0) { ERROR("Failed to create console mainloop");
ERROR("Failed to create console mainloop"); goto out_mainloop;
goto out_mainloop;
}
} }
ret = lxc_mainloop_add_handler(&descr, handler->sigfd, signal_handler, handler); ret = lxc_mainloop_add_handler(&descr, handler->sigfd, signal_handler, handler);
...@@ -495,20 +493,16 @@ int lxc_poll(const char *name, struct lxc_handler *handler) ...@@ -495,20 +493,16 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
goto out_mainloop_console; goto out_mainloop_console;
} }
if (has_console) { ret = lxc_console_mainloop_add(&descr, console);
struct lxc_console *console = &handler->conf->console; if (ret < 0) {
ERROR("Failed to add console handlers to mainloop");
ret = lxc_console_mainloop_add(&descr, console); goto out_mainloop_console;
if (ret < 0) { }
ERROR("Failed to add console handlers to mainloop");
goto out_mainloop_console;
}
ret = lxc_console_mainloop_add(&descr_console, console); ret = lxc_console_mainloop_add(&descr_console, console);
if (ret < 0) { if (ret < 0) {
ERROR("Failed to add console handlers to console mainloop"); ERROR("Failed to add console handlers to console mainloop");
goto out_mainloop_console; goto out_mainloop_console;
}
} }
ret = lxc_cmd_mainloop_add(name, &descr, handler); ret = lxc_cmd_mainloop_add(name, &descr, handler);
...@@ -525,19 +519,15 @@ int lxc_poll(const char *name, struct lxc_handler *handler) ...@@ -525,19 +519,15 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
if (ret < 0 || !handler->init_died) if (ret < 0 || !handler->init_died)
goto out_mainloop; goto out_mainloop;
if (has_console) ret = lxc_mainloop(&descr_console, 0);
ret = lxc_mainloop(&descr_console, 0);
out_mainloop: out_mainloop:
lxc_mainloop_close(&descr); lxc_mainloop_close(&descr);
TRACE("Closed mainloop"); TRACE("Closed mainloop");
out_mainloop_console: out_mainloop_console:
if (has_console) { lxc_mainloop_close(&descr_console);
lxc_mainloop_close(&descr_console); TRACE("Closed console mainloop");
TRACE("Closed console mainloop");
}
out_sigfd: out_sigfd:
close(handler->sigfd); close(handler->sigfd);
......
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