From 84d64b72a8006ca821b03f1a901266773e56e07a Mon Sep 17 00:00:00 2001 Message-Id: <84d64b72a8006ca821b03f1a901266773e56e07a.1381871412.git.jdenemar@redhat.com> From: "Daniel P. Berrange" Date: Mon, 14 Oct 2013 16:45:19 +0100 Subject: [PATCH] Make LXC controller use a private dbus connection & close it For https://bugzilla.redhat.com/show_bug.cgi?id=998365 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 (cherry picked from commit ae9a0485ae52aea6c7773176a15228abaa5de680) Signed-off-by: Jiri Denemark --- src/Makefile.am | 1 + src/lxc/lxc_controller.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/Makefile.am b/src/Makefile.am index 66bb6b9..5976a68 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2333,6 +2333,7 @@ libvirt_lxc_CFLAGS = \ $(PIE_CFLAGS) \ $(LIBNL_CFLAGS) \ $(FUSE_CFLAGS) \ + $(DBUS_CFLAGS) \ $(NULL) if WITH_BLKID libvirt_lxc_CFLAGS += $(BLKID_CFLAGS) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index ed73ab0..5802851 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -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; -- 1.8.3.2