mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 18:05:20 +00:00
Tweak container initialization to make upstart/init happier
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
This commit is contained in:
parent
57db02e8c0
commit
b70a1f455c
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user