]> xenbits.xensource.com Git - libvirt.git/commit
lxc: re-arrange startup synchronization sequence with controller
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 16 Jan 2015 15:03:16 +0000 (15:03 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 27 Jan 2015 13:57:02 +0000 (13:57 +0000)
commite1de5521506e10a1f50878cc3164b351f96d133d
tree1b46360055a3459e4c527c62dfba341e01481864
parenta5979e33749cb0d59c771c6214392a08e310363b
lxc: re-arrange startup synchronization sequence with controller

Currently the lxc controller process itself is responsible for
daemonizing itself into the background and writing out its pid
file. The lxc driver would fork the controller and then attempt
to connect to the lxc monitor. This connection would only
succeed after the controller has backgrounded itself, setup
cgroups and written its pid file, so startup was race free.

The problem is that we need to delay create of the cgroups to
much later, such that we can tell systemd the container init
pid when we create the cgroups. If we delay cgroup creation
though the current synchronization won't work.

A second problem is that the controller needs the XML config
of the guest. Currently we write out the plain virDomainDefPtr
XML before starting the controller, and then later replace it
with the full virDomainObjPtr status XML. This is kind of gross
and also means that the controller doesn't get a record of the
live XML config right away. This means it doesn't have a record
of the veth device names either and so can't give that info
to systemd when creating the cgroups.

To address this we change the startup sequencing. The goal
is that we want to get the PID as soon as possible, before
the LXC controller even starts. So we stop letting the LXC
controller daemonize itself, and instead use virCommand's
built-in capabilities. This daemonizes and writes the PID
before LXC controller is exec'd. So the driver can read
the PID as soon as virCommandRun returns. It is no longer
safe to connect to the monitor or detect the cgroups though.

Fortunately the LXC controller already has a second point
of synchronization. Immediately before its  event loop
starts running, it performs a handshake with the driver.
So we move the opening of the monitor connection and cgroup
detection after this synchronization point.
src/lxc/lxc_process.c