confile: config_start()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2017-05-30 04:35:17 +02:00
parent ec200ce926
commit ebb80f95b8
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D

View File

@ -1263,28 +1263,47 @@ static int config_pts(const char *key, const char *value,
}
static int config_start(const char *key, const char *value,
struct lxc_conf *lxc_conf)
struct lxc_conf *lxc_conf)
{
if (config_value_empty(value))
return 0;
bool is_empty;
if(strcmp(key, "lxc.start.auto") == 0) {
is_empty = config_value_empty(value);
if (strcmp(key, "lxc.start.auto") == 0) {
/* Set config value to default. */
if (is_empty) {
lxc_conf->start_auto = 0;
return 0;
}
/* Parse new config value. */
if (lxc_safe_uint(value, &lxc_conf->start_auto) < 0)
return -1;
if (lxc_conf->start_auto > 1)
return -1;
return 0;
} else if (strcmp(key, "lxc.start.delay") == 0) {
/* Set config value to default. */
if (is_empty) {
lxc_conf->start_delay = 0;
return 0;
}
/* Parse new config value. */
return lxc_safe_uint(value, &lxc_conf->start_delay);
} else if (strcmp(key, "lxc.start.order") == 0) {
/* Set config value to default. */
if (is_empty) {
lxc_conf->start_order = 0;
return 0;
}
/* Parse new config value. */
return lxc_safe_int(value, &lxc_conf->start_order);
}
else if (strcmp(key, "lxc.start.delay") == 0) {
if (lxc_safe_uint(value, &lxc_conf->start_delay) < 0)
return -1;
return 0;
}
else if (strcmp(key, "lxc.start.order") == 0) {
if (lxc_safe_int(value, &lxc_conf->start_order) < 0)
return -1;
return 0;
}
SYSERROR("Unknown key: %s", key);
return -1;
}