Upstart crashes & burns in a heap if $TERM environment variable is missing. Presumably the kernel always sets this when booting init on a real machine, so libvirt should set it for containers too. To make a typical inittab / mingetty setup happier, we need to symlink the primary console /dev/pts/0 to /dev/tty1. Improve logging in certain scenarios to make troubleshooting easier * src/lxc/lxc_container.c: Create /dev/tty1 and set $TERM --- src/lxc/lxc_container.c | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index c425154..b1e895d 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -105,8 +105,13 @@ static int lxcContainerExecInit(virDomainDefPtr vmDef) vmDef->os.init, NULL, }; + const char *const envp[] = { + "PATH=/bin:/sbin", + "TERM=linux", + NULL, + }; - return execve(argv[0], (char **)argv, NULL); + return execve(argv[0], (char **)argv,(char**)envp); } /** @@ -488,6 +493,15 @@ static int lxcContainerPopulateDevices(void) } } + /* XXX we should allow multiple consoles per container + * for tty2, tty3, etc, but the domain XML does not + * handle this yet + */ + if (symlink("/dev/pts/0", "/dev/tty1") < 0) { + virReportSystemError(errno, "%s", + _("Failed to symlink /dev/pts/0 to /dev/tty1")); + return -1; + } return 0; } @@ -822,15 +836,19 @@ int lxcContainerStart(virDomainDefPtr def, flags = CLONE_NEWPID|CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|SIGCHLD; - if (userns_supported()) + if (userns_supported()) { + DEBUG0("Enable user namespaces"); flags |= CLONE_NEWUSER; + } - if (def->nets != NULL) + if (def->nets != NULL) { + DEBUG0("Enable network namespaces"); flags |= CLONE_NEWNET; + } pid = clone(lxcContainerChild, stacktop, flags, &args); VIR_FREE(stack); - DEBUG("clone() returned, %d", pid); + DEBUG("clone() completed, new container PID is %d", pid); if (pid < 0) { virReportSystemError(errno, "%s", -- 1.6.6.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list