From 01d4faf05df4e0be4b5daa7e9468583bc2992c06 Mon Sep 17 00:00:00 2001 From: Dariusz Michaluk Date: Wed, 17 Dec 2014 15:46:59 +0100 Subject: [PATCH] Rearrange create zone process [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 --- server/configs/daemon.conf.in | 2 +- server/configs/templates/template.conf | 4 ++-- server/zones-manager.cpp | 20 +++++++++----------- tests/unit_tests/server/ut-zones-manager.cpp | 6 +++--- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/server/configs/daemon.conf.in b/server/configs/daemon.conf.in index 296c1c7..648d986 100644 --- a/server/configs/daemon.conf.in +++ b/server/configs/daemon.conf.in @@ -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", diff --git a/server/configs/templates/template.conf b/server/configs/templates/template.conf index 1939d51..fa6ef5c 100644 --- a/server/configs/templates/template.conf +++ b/server/configs/templates/template.conf @@ -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", diff --git a/server/zones-manager.cpp b/server/zones-manager.cpp index a0cb274..eafbe4b 100644 --- a/server/zones-manager.cpp +++ b/server/zones-manager.cpp @@ -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, diff --git a/tests/unit_tests/server/ut-zones-manager.cpp b/tests/unit_tests/server/ut-zones-manager.cpp index 07c03dd..4db9434 100644 --- a/tests/unit_tests/server/ut-zones-manager.cpp +++ b/tests/unit_tests/server/ut-zones-manager.cpp @@ -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 -- 2.7.4