Delay sending container to the background.
authorLukasz Pawelczyk <l.pawelczyk@partner.samsung.com>
Fri, 25 Apr 2014 14:02:55 +0000 (16:02 +0200)
committerJan Olszak <j.olszak@samsung.com>
Mon, 19 May 2014 11:47:16 +0000 (13:47 +0200)
[Bug/Feature]   Waiting for a dbus connection could take a long time.
[Cause]         The container was CPU throttled immediately after its
                start, this made it boot very slowly.
[Solution]      Throttle the container after the dbus connection is made.
[Verification]  Built, installed and run tests.

Change-Id: I9d69981bfd14820f71f1053a498b37b47a5bcfb1
Signed-off-by: Lukasz Pawelczyk <l.pawelczyk@partner.samsung.com>
server/container-admin.cpp
server/container.cpp
unit_tests/server/ut-container-admin.cpp

index 754f281..5f8d653 100644 (file)
@@ -114,11 +114,6 @@ void ContainerAdmin::start()
     }
 
     LOGD(mId << ": Started");
-    // TODO: the container should be started in the background,
-    // unfortunately libvirt doesn't allow us to set cgroups
-    // before the start, hence we do it immediately afterwards
-    LOGD(mId << ": Sending to the background");
-    setSchedulerLevel(SchedulerLevel::BACKGROUND);
 }
 
 
index 5e1368c..28ed3a6 100644 (file)
@@ -68,6 +68,11 @@ void Container::start()
     mConnection.initialize(mConfig.runMountPoint);
     mAdmin->start();
     mConnection.connect();
+
+    // Send to the background only after we're connected,
+    // otherwise it'd take ages.
+    LOGD(getId() << ": Sending to the background");
+    goBackground();
 }
 
 void Container::stop()
index 911131a..2e59e63 100644 (file)
@@ -143,7 +143,6 @@ BOOST_AUTO_TEST_CASE(SchedulerLevelTest)
     ContainerAdmin ca(config);
     BOOST_REQUIRE_NO_THROW(ca.start());
     ensureStarted();
-    BOOST_REQUIRE(ca.getSchedulerQuota() == config.cpuQuotaBackground);
     BOOST_REQUIRE_NO_THROW(ca.setSchedulerLevel(SchedulerLevel::FOREGROUND));
     BOOST_REQUIRE(ca.getSchedulerQuota() == config.cpuQuotaForeground);
     BOOST_REQUIRE_NO_THROW(ca.setSchedulerLevel(SchedulerLevel::BACKGROUND));