mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-14 04:56:31 +00:00
link /dev/kmsg to /dev/console in the container
This way init log messages can be seen on the console. If containerized syslog ever comes around, we can get rid of this. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
5d38621d0b
commit
1bd051a6b0
@ -1055,6 +1055,31 @@ static int setup_console(const struct lxc_rootfs *rootfs,
|
||||
return setup_ttydir_console(rootfs, console, ttydir);
|
||||
}
|
||||
|
||||
static int setup_kmsg(const struct lxc_rootfs *rootfs,
|
||||
const struct lxc_console *console)
|
||||
{
|
||||
char kpath[MAXPATHLEN];
|
||||
int ret;
|
||||
|
||||
ret = snprintf(kpath, sizeof(kpath), "%s/dev/kmsg", rootfs->mount);
|
||||
if (ret < 0 || ret >= sizeof(kpath))
|
||||
return -1;
|
||||
|
||||
ret = unlink(kpath);
|
||||
if (ret && errno != ENOENT) {
|
||||
SYSERROR("error unlinking %s\n", kpath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = symlink("console", kpath);
|
||||
if (ret) {
|
||||
SYSERROR("failed to create symlink for kmsg");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int setup_cgroup(const char *name, struct lxc_list *cgroups)
|
||||
{
|
||||
struct lxc_list *iterator;
|
||||
@ -2167,6 +2192,11 @@ int lxc_setup(const char *name, struct lxc_conf *lxc_conf)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (setup_kmsg(&lxc_conf->rootfs, &lxc_conf->console)) {
|
||||
ERROR("failed to setup kmsg for '%s'", name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (setup_tty(&lxc_conf->rootfs, &lxc_conf->tty_info, lxc_conf->ttydir)) {
|
||||
ERROR("failed to setup the ttys for '%s'", name);
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user