]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Create console when the rootfs is NULL
authorLiFeng <lifeng68@huawei.com>
Thu, 18 Jan 2018 22:26:11 +0000 (17:26 -0500)
committerLiFeng <lifeng68@huawei.com>
Thu, 18 Jan 2018 23:06:46 +0000 (18:06 -0500)
Signed-off-by: LiFeng <lifeng68@huawei.com>
src/lxc/console.c
src/lxc/start.c

index f875f8461b86e8bca80806be65607481376f7748..d613d79874defa6712ad3dcf906cd56144ebd95a 100644 (file)
@@ -747,12 +747,6 @@ int lxc_console_create(struct lxc_conf *conf)
        int ret;
        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")) {
                INFO("No console was requested");
                return 0;
index 89a194fd1c45c83fc30ea312457e8a9f930e50c4..97e3231f1709c79bb36c4efa2bb6a1d8e56d3867 100644 (file)
@@ -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 ret;
-       bool has_console = (handler->conf->rootfs.path != NULL);
+       struct lxc_console *console = &handler->conf->console;
        struct lxc_epoll_descr descr, descr_console;
 
        ret = lxc_mainloop_open(&descr);
@@ -481,12 +481,10 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
                goto out_sigfd;
        }
 
-       if (has_console) {
-               ret = lxc_mainloop_open(&descr_console);
-               if (ret < 0) {
-                       ERROR("Failed to create console mainloop");
-                       goto out_mainloop;
-               }
+       ret = lxc_mainloop_open(&descr_console);
+       if (ret < 0) {
+               ERROR("Failed to create console mainloop");
+               goto out_mainloop;
        }
 
        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)
                goto out_mainloop_console;
        }
 
-       if (has_console) {
-               struct lxc_console *console = &handler->conf->console;
-
-               ret = lxc_console_mainloop_add(&descr, console);
-               if (ret < 0) {
-                       ERROR("Failed to add console handlers to mainloop");
-                       goto out_mainloop_console;
-               }
+       ret = lxc_console_mainloop_add(&descr, console);
+       if (ret < 0) {
+               ERROR("Failed to add console handlers to mainloop");
+               goto out_mainloop_console;
+       }
 
-               ret = lxc_console_mainloop_add(&descr_console, console);
-               if (ret < 0) {
-                       ERROR("Failed to add console handlers to console mainloop");
-                       goto out_mainloop_console;
-               }
+       ret = lxc_console_mainloop_add(&descr_console, console);
+       if (ret < 0) {
+               ERROR("Failed to add console handlers to console mainloop");
+               goto out_mainloop_console;
        }
 
        ret = lxc_cmd_mainloop_add(name, &descr, handler);
@@ -525,19 +519,15 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
        if (ret < 0 || !handler->init_died)
                goto out_mainloop;
 
-       if (has_console)
-               ret = lxc_mainloop(&descr_console, 0);
-
+       ret = lxc_mainloop(&descr_console, 0);
 
 out_mainloop:
        lxc_mainloop_close(&descr);
        TRACE("Closed mainloop");
 
 out_mainloop_console:
-       if (has_console) {
-               lxc_mainloop_close(&descr_console);
-               TRACE("Closed console mainloop");
-       }
+       lxc_mainloop_close(&descr_console);
+       TRACE("Closed console mainloop");
 
 out_sigfd:
        close(handler->sigfd);