lxcpp: provisioning implementation (part 2)
[platform/core/security/vasum.git] / server / zone-config.hpp
1 /*
2  *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Contact: Michal Witanowski <m.witanowski@samsung.com>
5  *
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
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
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
17  */
18
19 /**
20  * @file
21  * @author  Michal Witanowski (m.witanowski@samsung.com)
22  * @brief   Declaration of the class for storing zone configuration
23  */
24
25
26 #ifndef SERVER_ZONE_CONFIG_HPP
27 #define SERVER_ZONE_CONFIG_HPP
28
29 #include "config/fields.hpp"
30
31 #include <string>
32 #include <vector>
33
34
35 namespace vasum {
36
37
38 struct ZoneConfig {
39
40     /**
41      * Zone template name (relative to zoneTemplateDir)
42      */
43     std::string zoneTemplate;
44
45     /**
46      * Init program with args (empty means default /sbin/init)
47      */
48     std::vector<std::string> initWithArgs;
49
50     /**
51      * Privilege of the zone.
52      * The smaller the value the more important the zone
53      */
54     int privilege;
55
56     /**
57      * Allow switching to default zone after timeout.
58      * Setting this to false will disable switching to default zone after timeout.
59      */
60     bool switchToDefaultAfterTimeout;
61
62     /**
63      * Zone's CFS quota in us when it's in the foreground
64      */
65     std::int64_t cpuQuotaForeground;
66
67     /**
68      * Zone's CFS quota in us when it's in the background
69      */
70     std::int64_t cpuQuotaBackground;
71
72     /**
73      * Valid hard link prefixes.
74      */
75     std::vector<std::string> validLinkPrefixes;
76
77     /**
78      * Timeout in seconds for zone to gracefully shut down.
79      * After given time, if Zone is not off, forced shutdown occurs.
80      *
81      * To wait forever, set -1 timeout. To skip waiting, set 0 timeout.
82      */
83     int shutdownTimeout;
84
85     CONFIG_REGISTER
86     (
87         zoneTemplate,
88         initWithArgs,
89         privilege, // TODO not needed?
90         switchToDefaultAfterTimeout, // TODO move to dynamic and add an API to change
91         cpuQuotaForeground,
92         cpuQuotaBackground,
93         validLinkPrefixes,
94         shutdownTimeout
95     )
96 };
97
98 struct ZoneDynamicConfig {
99
100     /**
101      * Requested zone state after restore
102      */
103     std::string requestedState;
104
105     /**
106      * IP v4 gateway address
107      */
108     std::string ipv4Gateway;
109
110     /**
111      * IP v4 address
112      */
113     std::string ipv4;
114
115     /**
116      * Number of virtual terminal used by xserver inside zone
117      */
118     int vt;
119
120     /**
121      * Path to zones dbus unix socket
122      */
123     std::string runMountPoint;
124
125     CONFIG_REGISTER
126     (
127         requestedState,
128         ipv4Gateway,
129         ipv4,
130         vt,
131         runMountPoint
132     )
133 };
134
135 struct ZoneTemplatePathConfig {
136     /**
137      * A path to zone template config (containing default values)
138      */
139     std::string zoneTemplatePath;
140
141     CONFIG_REGISTER(zoneTemplatePath)
142 };
143
144 } // namespace vasum
145
146 #endif // SERVER_ZONE_CONFIG_HPP