]> git.proxmox.com Git - mirror_lxc.git/commit - src/lxc/lxccontainer.c
start: use separate socket on daemonized start
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 29 Jun 2017 10:16:00 +0000 (12:16 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sat, 8 Jul 2017 21:50:18 +0000 (23:50 +0200)
commit5e5576a4ef2d6f4a1abce6b8e0ff68edebdde47f
treef0f1e6d8e31e95204f630c1521c300a603aa4017
parent47a46cf1d28aad270072a983910d881d9c6e14aa
start: use separate socket on daemonized start

Since we killed lxc-monitord we rely on the container's command socket to wait
for the container. This doesn't work nicely on daemonized startup since a
container's init process might be something that is so short-lived that we
won't even be able to add a state client before the mainloop closes. But the
container might still have been RUNNING and executed the init binary correctly.
In this case we would erroneously report that the container failed to start
when it actually started just fine.
This commit ensures that we really all cases where the container successfully
ran by switching to a short-lived per-container anonymous unix socket pair that
uses credentials to pass container states around. It is immediately closed once
the container has started successfully.
This should also make daemonized container start way more robust since we don't
rely on the command socket handler to be running.

For the experienced developer: Yes, I did think about utilizing the command
socket directly for this. The problem is that when the mainloop starts it may
end up end accept()ing the connection that we want
do_wait_on_daemonized_start() to accept() so this won't work and might cause us
to hang indefinitely. The same problem arises when the container fails to start
before the mainloop is created. In this case we would hang indefinitely as
well.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/criu.c
src/lxc/lxccontainer.c
src/lxc/start.c
src/lxc/start.h