43fe83
From 84d64b72a8006ca821b03f1a901266773e56e07a Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <84d64b72a8006ca821b03f1a901266773e56e07a.1381871412.git.jdenemar@redhat.com>
43fe83
From: "Daniel P. Berrange" <berrange@redhat.com>
43fe83
Date: Mon, 14 Oct 2013 16:45:19 +0100
43fe83
Subject: [PATCH] Make LXC controller use a private dbus connection & close it
43fe83
43fe83
For
43fe83
43fe83
  https://bugzilla.redhat.com/show_bug.cgi?id=998365
43fe83
43fe83
The LXC controller uses dbus to talk to systemd to create
43fe83
cgroups. This means that each LXC controller instance has
43fe83
a dbus connection. The DBus daemon is limited to 256
43fe83
connections by default and we want to be able to run many
43fe83
1000 of containers.
43fe83
43fe83
While the dbus limit could be raised in the config files,
43fe83
it is simpler to make libvirt LXC controller close its
43fe83
dbus connection once everything is configured.
43fe83
43fe83
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
43fe83
(cherry picked from commit ae9a0485ae52aea6c7773176a15228abaa5de680)
43fe83
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
43fe83
---
43fe83
 src/Makefile.am          | 1 +
43fe83
 src/lxc/lxc_controller.c | 9 +++++++++
43fe83
 2 files changed, 10 insertions(+)
43fe83
43fe83
diff --git a/src/Makefile.am b/src/Makefile.am
43fe83
index 66bb6b9..5976a68 100644
43fe83
--- a/src/Makefile.am
43fe83
+++ b/src/Makefile.am
43fe83
@@ -2333,6 +2333,7 @@ libvirt_lxc_CFLAGS =				\
43fe83
 		$(PIE_CFLAGS)			\
43fe83
 		$(LIBNL_CFLAGS)			\
43fe83
 		$(FUSE_CFLAGS)			\
43fe83
+		$(DBUS_CFLAGS)			\
43fe83
 		$(NULL)
43fe83
 if WITH_BLKID
43fe83
 libvirt_lxc_CFLAGS += $(BLKID_CFLAGS)
43fe83
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
43fe83
index ed73ab0..5802851 100644
43fe83
--- a/src/lxc/lxc_controller.c
43fe83
+++ b/src/lxc/lxc_controller.c
43fe83
@@ -64,6 +64,7 @@
43fe83
 #include "virrandom.h"
43fe83
 #include "virprocess.h"
43fe83
 #include "virnuma.h"
43fe83
+#include "virdbus.h"
43fe83
 #include "rpc/virnetserver.h"
43fe83
 #include "virstring.h"
43fe83
 
43fe83
@@ -2200,6 +2201,12 @@ virLXCControllerRun(virLXCControllerPtr ctrl)
43fe83
         if (virLXCControllerConsoleSetNonblocking(&(ctrl->consoles[i])) < 0)
43fe83
             goto cleanup;
43fe83
 
43fe83
+    /* We must not hold open a dbus connection for life
43fe83
+     * of LXC instance, since dbus-daemon is limited to
43fe83
+     * only a few 100 connections by default
43fe83
+     */
43fe83
+    virDBusCloseSystemBus();
43fe83
+
43fe83
     rc = virLXCControllerMain(ctrl);
43fe83
 
43fe83
     virLXCControllerEventSendExit(ctrl, rc);
43fe83
@@ -2351,6 +2358,8 @@ int main(int argc, char *argv[])
43fe83
 
43fe83
     virEventRegisterDefaultImpl();
43fe83
 
43fe83
+    virDBusSetSharedBus(false);
43fe83
+
43fe83
     if (!(ctrl = virLXCControllerNew(name)))
43fe83
         goto cleanup;
43fe83
 
43fe83
-- 
43fe83
1.8.3.2
43fe83