]> git.proxmox.com Git - mirror_lxc.git/commit - src/lxc/commands.c
commands: add lxc_cmd_state_server()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 10 Jun 2017 23:29:45 +0000 (01:29 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 13 Jun 2017 04:13:20 +0000 (06:13 +0200)
commitdbc9832d217d812f68184cc431bfc5ac559e5dfa
tree7a7c6be3840abed2bf56220f6c6c12986b34f0f0
parent3f903c04fea9e59c2057defd8e906d20199b7203
commands: add lxc_cmd_state_server()

A LXC container's lifecycle is regulated by the states STARTING, RUNNING,
STOPPING, STOPPED, ABORTING. These states are tracked in the LXC handler and
can be checked via approriate functions in the command socket callback system.
(The freezer stages are not part of a container's lifecycle since they are not
recorded in the LXC handler. This might change in the future but given that the
freezer controller will be removed from future cgroup implementations it is
unlikely.) So far, LXC was using an external helper to track the states of a
container (lxc-monitord). This solution was error prone. For example, the
external state server would hang in various scenarios that seemed to be caused
by either very subtle internal races or irritation of the external state server
by signals.

LXC will switch from an external state monitor (lxc-monitord) which serves as a
state server for state clients to a native implementation using the indiviual
container's command socket. This solution was discussed and outlined by Stéphane
Graber and Christian Brauner during a LX{C,D} sprint.

The LXC handler will gain an additional field to track state clients. In order
for a state client to receive state notifications from the command server he
will need to register himself via the lxc_cmd_state_server() function in the
state client list. The state client list will be served by lxc_set_state()
during the container's lifecycle. lxc_set_state() will also take care of
removing any clients from the state list in the LXC handler once the requested
state has been reached and sent to the client.
In order to prevent races between adding and serving new state clients the state
client list and the state field in the LXC handler will be protected by a lock.

This commit effectively deprecates lxc-monitord. Instead of serving states to
state clients via the lxc-monitord fifo and socket we will now send the state
of the container via the container's command socket.
lxc-monitord is still useable and will - for the sake of the lxc-monitor
command - be kept around so that non-API state clients can still monitor the
container during it's lifecycle.

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