Rearrange create zone process 92/32392/3
authorDariusz Michaluk <d.michaluk@samsung.com>
Wed, 17 Dec 2014 14:46:59 +0000 (15:46 +0100)
committerDariusz Michaluk <d.michaluk@samsung.com>
Thu, 18 Dec 2014 13:22:45 +0000 (14:22 +0100)
[Bug/Feature]   Remove start functionality, add VT support.
[Cause]         N/A
[Solution]      N/A
[Verification]  Build, install, run tests

Change-Id: I67a7eebf6e45bb2cab29e833fbf53c1bdaeb88fb
Signed-off-by: Dariusz Michaluk <d.michaluk@samsung.com>
server/configs/daemon.conf.in
server/configs/templates/template.conf
server/zones-manager.cpp
tests/unit_tests/server/ut-zones-manager.cpp

index 296c1c7..648d986 100644 (file)
@@ -1,7 +1,7 @@
 {
     "zoneConfigs" : ["zones/private.conf", "zones/business.conf"],
     "zonesPath" : "${DATA_DIR}/.zones",
-    "zoneImagePath" : "${DATA_DIR}/.zones/img/system-data.img",
+    "zoneImagePath" : "",
     "zoneTemplatePath" : "templates",
     "zoneNewConfigPrefix" : "/var/lib/vasum",
     "runMountPointPrefix" : "/var/run/zones",
index 1939d51..fa6ef5c 100644 (file)
@@ -1,13 +1,13 @@
 {
     "name" : "~NAME~",
-    "lxcTemplate" : "template.sh",
+    "lxcTemplate" : "tizen-common-wayland.sh",
     "initWithArgs" : [],
     "ipv4Gateway" : "10.0.~IP~.1",
     "ipv4" : "10.0.~IP~.2",
     "cpuQuotaForeground" : -1,
     "cpuQuotaBackground" : 1000,
     "privilege" : 10,
-    "vt" : -1,
+    "vt" : ~VT~,
     "switchToDefaultAfterTimeout" : true,
     "enableDbusIntegration" : true,
     "runMountPoint" : "~NAME~/run",
index a0cb274..eafbe4b 100644 (file)
@@ -69,8 +69,10 @@ const std::string ENABLED_FILE_NAME = "enabled";
 
 const boost::regex ZONE_NAME_REGEX("~NAME~");
 const boost::regex ZONE_IP_THIRD_OCTET_REGEX("~IP~");
+const boost::regex ZONE_VT_REGEX("~VT~");
 
 const unsigned int ZONE_IP_BASE_THIRD_OCTET = 100;
+const unsigned int ZONE_VT_BASE = 1;
 
 } // namespace
 
@@ -764,6 +766,12 @@ void ZonesManager::generateNewConfig(const std::string& id,
     LOGD("IP third octet: " << thirdOctetStr);
     resultConfig = boost::regex_replace(resultConfig, ZONE_IP_THIRD_OCTET_REGEX, thirdOctetStr);
 
+    // generate first free VT number
+    // TODO change algorithm after implementing removeZone
+    std::string freeVT = std::to_string(ZONE_VT_BASE + mZones.size() + 1);
+    LOGD("VT number: " << freeVT);
+    resultConfig = boost::regex_replace(resultConfig, ZONE_VT_REGEX, freeVT);
+
     if (!utils::saveFileContent(resultPath, resultConfig)) {
         LOGE("Faield to save new config file.");
         throw ZoneOperationException("Failed to save new config file.");
@@ -854,17 +862,7 @@ void ZonesManager::handleCreateZoneCall(const std::string& id,
         return;
     }
 
-    auto resultCallback = [this, id, result](bool succeeded) {
-        if (succeeded) {
-            focus(id);
-            result->setVoid();
-        } else {
-            LOGE("Failed to start zone.");
-            // TODO removeZone
-            result->setError(api::ERROR_INTERNAL, "Failed to start zone");
-        }
-    };
-    mZones[id]->startAsync(resultCallback);
+    result->setVoid();
 }
 
 void ZonesManager::handleDestroyZoneCall(const std::string& id,
index 07c03dd..4db9434 100644 (file)
@@ -1065,16 +1065,16 @@ BOOST_AUTO_TEST_CASE(CreateDestroyZoneTest)
     dbus.callAsyncMethodCreateZone(zone1, resultCallback);
     BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
 
-    BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), zone1);
-
     // create zone2
     dbus.callAsyncMethodCreateZone(zone2, resultCallback);
     BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
-    BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), zone2); //TODO is this valid?
 
     // create zone3
     dbus.callAsyncMethodCreateZone(zone3, resultCallback);
     BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
+
+    cm.startAll();
+
     BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), zone3);
 
     // destroy zone2