]> xenbits.xensource.com Git - libvirt.git/commitdiff
Make LXC controller use a private dbus connection & close it
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 11 Oct 2013 14:57:31 +0000 (15:57 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 14 Oct 2013 09:31:01 +0000 (10:31 +0100)
The LXC controller uses dbus to talk to systemd to create
cgroups. This means that each LXC controller instance has
a dbus connection. The DBus daemon is limited to 256
connections by default and we want to be able to run many
1000 of containers.

While the dbus limit could be raised in the config files,
it is simpler to make libvirt LXC controller close its
dbus connection once everything is configured.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/Makefile.am
src/lxc/lxc_controller.c

index 201c26816d7eafff72cf06d7d0995adff10ad677..e58d4086c80ca357e21db1caecf51fba0d808dda 100644 (file)
@@ -2381,6 +2381,7 @@ libvirt_lxc_CFLAGS =                              \
                $(PIE_CFLAGS)                   \
                $(LIBNL_CFLAGS)                 \
                $(FUSE_CFLAGS)                  \
+               $(DBUS_CFLAGS)                  \
                $(NULL)
 if WITH_BLKID
 libvirt_lxc_CFLAGS += $(BLKID_CFLAGS)
index bb33c2823cab2f25e9df1de1d77f2375ff3490ed..b881f172de94948f52bcf113510ff4f46160c5bf 100644 (file)
@@ -64,6 +64,7 @@
 #include "virrandom.h"
 #include "virprocess.h"
 #include "virnuma.h"
+#include "virdbus.h"
 #include "rpc/virnetserver.h"
 #include "virstring.h"
 
@@ -2200,6 +2201,12 @@ virLXCControllerRun(virLXCControllerPtr ctrl)
         if (virLXCControllerConsoleSetNonblocking(&(ctrl->consoles[i])) < 0)
             goto cleanup;
 
+    /* We must not hold open a dbus connection for life
+     * of LXC instance, since dbus-daemon is limited to
+     * only a few 100 connections by default
+     */
+    virDBusCloseSystemBus();
+
     rc = virLXCControllerMain(ctrl);
 
     virLXCControllerEventSendExit(ctrl, rc);
@@ -2351,6 +2358,8 @@ int main(int argc, char *argv[])
 
     virEventRegisterDefaultImpl();
 
+    virDBusSetSharedBus(false);
+
     if (!(ctrl = virLXCControllerNew(name)))
         goto cleanup;