2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Piotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
21 * @author Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
25 #ifndef COMMON_LXC_ZONE_HPP
26 #define COMMON_LXC_ZONE_HPP
29 #include <sys/types.h>
31 // fwd declaration of lxc internals
39 * A class wrapping lxc container
56 * @param lxcPath path where zones lives
57 * @param zoneName name of zone
59 LxcZone(const std::string& lxcPath, const std::string& zoneName);
62 LxcZone(const LxcZone&) = delete;
63 LxcZone& operator=(const LxcZone&) = delete;
68 std::string getName() const;
71 * Get item from lxc config file
72 * @throw LxcException if key not found
74 std::string getConfigItem(const std::string& key);
77 * Is zone defined (created)?
82 * String representation of state
84 static std::string toString(State state);
92 * Wait till zone is in specified state
93 * @return false on timeout
95 bool waitForState(State state, int timeout);
99 * @param templatePath template from which zone will be created
100 * @param argv additional template arguments
102 bool create(const std::string& templatePath, const char* const* argv);
111 * @param argv init process with arguments
113 bool start(const char* const* argv);
116 * Immediate stop the zone
117 * It kills all processes within this zone
127 * Gracefully shutdown zone.
129 bool shutdown(int timeout);
132 * Freeze (pause/lock) zone
142 * Get pid of init process
144 pid_t getInitPid() const;
147 lxc_container* mLxcContainer;
149 bool setRunLevel(int runLevel);
158 #endif // COMMON_LXC_ZONE_HPP