]> git.proxmox.com Git - mirror_lxc.git/commit
create lxc.tty ptys from container process
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 29 Jan 2015 10:13:36 +0000 (10:13 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 29 Jan 2015 10:46:02 +0000 (11:46 +0100)
commite8bd4e430bf76ed4737563476ce685b2425412ec
treed32a194da67667a2136d4e9b3735c96c71bebeaf
parentf24a52d5f588ff4e4575046903fb9498c376d833
create lxc.tty ptys from container process

Lxc has always created the ptys for use by console and ttys early
on from the monitor process.  This has some advantages, but also
has disadvantages, namely (1) container ptys counting against the
max ptys for the host, and (2) not having a /dev/pts/N in the
container to pass to getty.  (2) was not a problem for us historically
because we bind-mounted the host's /dev/pts/N onto a /dev/ttyN in
the container.  However, systemd hardocdes a check for container_ttys
that the path have 'pts/' in it.  If it were only for (2) I'd have
opted for a systemd patch to check the device major number, but (1)
made it worth moving the openpty to the container namespace.

So this patch moves the tty creation into the task which becomes
the container init.  It then passes the fds for the opened ptys
back to the monitor over a unix socketpair (for use by lxc-console).
The /dev/console is still created in the monitor process, so that
it can for instance be used by lxc.logfd.

So now if you have a foreground container with lxc.tty = 4, you
should end up with one host /dev/pts entry per container rather than 5.

And lxc-console now works with systemd containers.

Note that if the container init mounts its own devpts over the
one mounted by lxc, the tty /dev/pts/n will be hidden.  This is ok
since it's only systemd that needs it, and systemd won't do that.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
config/apparmor/abstractions/start-container
config/apparmor/profiles/lxc-default-with-nesting
src/lxc/conf.c
src/lxc/start.c
src/lxc/start.h