]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: config_start()
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 30 May 2017 02:35:17 +0000 (04:35 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 30 May 2017 16:43:04 +0000 (18:43 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/confile.c

index b9a457209283b5b22f70fa4be71fe695c947c02f..5ad386a5ad78c212f35b0e89f9b76a4161668ee8 100644 (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;
+
+       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;
+               }
 
-       if(strcmp(key, "lxc.start.auto") == 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;
 }