Haven't tested this, but I think the following patch should fix the
race, by forcing lxc_driver to hang on lxcMonitorClient() until
after the lxc_controller has set up the cgroups, ensuring that that
happens before the driver is unlocked.
(I'll test tomorrow)
Index: libvirt-0.9.2/src/lxc/lxc_controller.c
===================================================================
--- libvirt-0.9.2.orig/src/lxc/lxc_controller.c 2011-10-02 20:30:23.988539174 -0500
+++ libvirt-0.9.2/src/lxc/lxc_controller.c 2011-10-02 20:30:34.392538998 -0500
@@ -611,7 +611,6 @@
unsigned int nveths,
char **veths,
int monitor,
- int client,
int appPty)
{
int rc = -1;
@@ -622,6 +621,7 @@
virDomainFSDefPtr root;
char *devpts = NULL;
char *devptmx = NULL;
+ int client;
if (socketpair(PF_UNIX, SOCK_STREAM, 0, control) < 0) {
virReportSystemError(errno, "%s",
@@ -634,6 +634,13 @@
if (lxcSetContainerResources(def) < 0)
goto cleanup;
+ /* Accept initial client which is the libvirtd daemon */
+ if ((client = accept(monitor, NULL, 0)) < 0) {
+ virReportSystemError(errno, "%s",
+ _("Failed to accept a connection from driver"));
+ goto cleanup;
+ }
+
/*
* If doing a chroot style setup, we need to prepare
* a private /dev/pts for the child now, which they
@@ -922,14 +929,7 @@
/* Initialize logging */
virLogSetFromEnv();
- /* Accept initial client which is the libvirtd daemon */
- if ((client = accept(monitor, NULL, 0)) < 0) {
- virReportSystemError(errno, "%s",
- _("Failed to accept a connection from driver"));
- goto cleanup;
- }
-
- rc = lxcControllerRun(def, nveths, veths, monitor, client, appPty);
+ rc = lxcControllerRun(def, nveths, veths, monitor, appPty);
cleanup: