Add timeout after zone start. 90/36290/4
authorDariusz Michaluk <d.michaluk@samsung.com>
Wed, 4 Mar 2015 09:26:16 +0000 (10:26 +0100)
committerDariusz Michaluk <d.michaluk@samsung.com>
Thu, 12 Mar 2015 07:50:33 +0000 (00:50 -0700)
[Bug/Feature]   Add timeout after zone start.
[Cause]         N/A
[Solution]      N/A
[Verification]  Build, run server, run tests

Change-Id: Ie6adace3d36ad98756d8efc823a056356f41d02d
Signed-off-by: Dariusz Michaluk <d.michaluk@samsung.com>
server/zone-admin.cpp
server/zone-admin.hpp

index 519b172..8005fb4 100644 (file)
@@ -35,6 +35,8 @@
 
 #include <cassert>
 #include <climits>
+#include <thread>
+#include <chrono>
 
 
 namespace vasum {
@@ -55,6 +57,7 @@ ZoneAdmin::ZoneAdmin(const std::string& zoneId,
                      const ZoneConfig& config,
                      const ZoneDynamicConfig& dynamicConfig)
     : mConfig(config),
+      mDynamicConfig(dynamicConfig),
       mZone(zonesPath, zoneId),
       mId(zoneId),
       mDetachOnExit(false),
@@ -138,6 +141,16 @@ void ZoneAdmin::start()
         throw ZoneOperationException("Could not start zone");
     }
 
+    // Wait until the full platform launch with graphical stack.
+    // VT should be activated by a graphical stack.
+    // If we do it with 'zoneToFocus.activateVT' before starting the graphical stack,
+    // graphical stack initialization failed and we finally switch to the black screen.
+    // Skip waiting when graphical stack is not running (unit tests).
+    if (mDynamicConfig.vt > 0) {
+        // TODO, timeout is a temporary solution
+        std::this_thread::sleep_for(std::chrono::milliseconds(4000));
+    }
+
     LOGD(mId << ": Started");
 }
 
index 44d2613..ade4585 100644 (file)
@@ -166,6 +166,7 @@ public:
 
 private:
     const ZoneConfig& mConfig;
+    const ZoneDynamicConfig& mDynamicConfig;
     lxc::LxcZone mZone;
     const std::string mId;
     bool mDetachOnExit;