]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: make update warning opt-in 1849/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 10 Oct 2017 12:35:40 +0000 (14:35 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 10 Oct 2017 12:35:40 +0000 (14:35 +0200)
With the release LXC 2.1 we started warning users who use LXC through the API
and users who use LXC through the tools equally about updating their config.
This quickly got confusing and annoying to API users who e.g. generate configs
on the fly (e.g. LXD). So instead of unconditionally warning users we make this
opt-in. If LXC detects that the env variable LXC_UPDATE_CONFIG_FORMAT is set
then it will warn the user if any legacy configuration keys are present. If it
is not set however, it will not warn the user. This is ok, since the log will
still log WARN()s for all legacy configuration keys.
The tools will all set LXC_UPDATE_CONFIG_FORMAT since it is very much required
that users update to the new configuration format pre-LXC 3.0.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
22 files changed:
src/lxc/confile.c
src/lxc/tools/lxc_attach.c
src/lxc/tools/lxc_autostart.c
src/lxc/tools/lxc_cgroup.c
src/lxc/tools/lxc_checkpoint.c
src/lxc/tools/lxc_clone.c
src/lxc/tools/lxc_config.c
src/lxc/tools/lxc_console.c
src/lxc/tools/lxc_copy.c
src/lxc/tools/lxc_create.c
src/lxc/tools/lxc_destroy.c
src/lxc/tools/lxc_device.c
src/lxc/tools/lxc_execute.c
src/lxc/tools/lxc_freeze.c
src/lxc/tools/lxc_info.c
src/lxc/tools/lxc_ls.c
src/lxc/tools/lxc_monitor.c
src/lxc/tools/lxc_snapshot.c
src/lxc/tools/lxc_start.c
src/lxc/tools/lxc_stop.c
src/lxc/tools/lxc_unfreeze.c
src/lxc/tools/lxc_wait.c

index e9435343d2d98a966f45f97fcdb0a5ee71c0db04..4850e4ce5b240f2d00f600abac898989a7f9c432 100644 (file)
@@ -2009,13 +2009,15 @@ static int parse_line(char *buffer, void *data)
        /* [START]: REMOVE IN LXC 3.0 */
        if (config->is_legacy_key && !plc->conf->contains_legacy_key) {
                plc->conf->contains_legacy_key = true;
-               /* Warn the user once loud and clear that there is at least one
-                * legacy configuration item in the configuration file and then
-                * an update is required.
-                */
-               fprintf(stderr, "The configuration file contains legacy "
-                               "configuration keys.\nPlease update your "
-                               "configuration file!\n");
+               if (getenv("LXC_UPDATE_CONFIG_FORMAT")) {
+                       /* Warn the user once loud and clear that there is at
+                        * least one legacy configuration item in the
+                        * configuration file and then an update is required.
+                        */
+                       fprintf(stderr, "The configuration file contains "
+                                       "legacy configuration keys.\nPlease "
+                                       "update your configuration file!\n");
+               }
        }
        /* [END]: REMOVE IN LXC 3.0 */
 
index 6ae33ae3d19c584fa0ed2283c1d45c5444e4968f..cab75ca765ed40243d708b7f194fed1a9d201916 100644 (file)
@@ -406,6 +406,9 @@ int main(int argc, char *argv[])
                }
        }
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        struct lxc_container *c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
        if (!c)
                exit(EXIT_FAILURE);
index f171f73b126aecaf1f6eb21a63b7b463b22d8c0a..69798806bd0780797c4c3f153027b13d519b60cd 100644 (file)
@@ -368,6 +368,9 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        count = list_defined_containers(my_args.lxcpath[0], NULL, &containers);
 
        if (count < 0)
index db65c3d3d2eb02e4eaf72187812eab669e3474dd..b8057b68c9f3879ff78c6127f40c710f8ac9ec7a 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <libgen.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
-#include <libgen.h>
 #include <sys/types.h>
 
 #include <lxc/lxccontainer.h>
 
-#include "lxc.h"
-#include "log.h"
 #include "arguments.h"
+#include "log.h"
+#include "lxc.h"
 
 lxc_log_define(lxc_cgroup_ui, lxc);
 
@@ -86,6 +87,9 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        state_object = my_args.argv[0];
 
        c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
index 19c63f8d39450a4a77759bb77639b6c4e15a205a..8f93934b3733e7b6167d83c0e5d3ce84d10955a5 100644 (file)
@@ -255,6 +255,9 @@ int main(int argc, char *argv[])
 
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
        if (!c) {
                fprintf(stderr, "System error loading %s\n", my_args.name);
index b1062c822641ece00c3882fd3ed34410eb630ddf..30521192b8c83dae134d43daa09bf1025169f9ba 100644 (file)
@@ -176,6 +176,8 @@ int main(int argc, char *argv[])
                usage(argv[0]);
        }
 
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        c1 = lxc_container_new(orig, lxcpath);
        if (!c1)
                exit(EXIT_FAILURE);
index c26b1a0aa8b596fc1b671d7f13c0941eae2e2a81..c204447ae744499c5dd875583166d91e6c6bdb14 100644 (file)
@@ -62,6 +62,8 @@ int main(int argc, char *argv[])
        struct lxc_config_items *i;
        const char *value;
 
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        if (argc < 2)
                usage(argv[0]);
        if (strcmp(argv[1], "-l") == 0)
index e1e6548010f225aba6c73b3de62e7b3008409b4e..66b9091624256ed22028de82affd4007cad9a19d 100644 (file)
@@ -119,6 +119,9 @@ int main(int argc, char *argv[])
                return EXIT_FAILURE;
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
        if (!c) {
                fprintf(stderr, "System error loading container\n");
index f1b51c4c7ba3d44e3a7d888311c5fc04410e0cb7..7eddb77d6f39e4377d9c39a5517e53a5cb513357 100644 (file)
@@ -190,6 +190,9 @@ int main(int argc, char *argv[])
                exit(ret);
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        if (geteuid()) {
                if (access(my_args.lxcpath[0], O_RDONLY) < 0) {
                        if (!my_args.quiet)
index 7d925f5e0d4280474bf81ab0ae5ee9e972f99ebb..181ee7d920b8af1ae69d145e7c1b22714d1588dc 100644 (file)
@@ -229,6 +229,9 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        if (!my_args.template) {
                fprintf(stderr, "A template must be specified.\n");
                fprintf(stderr, "Use \"none\" if you really want a container without a rootfs.\n");
index 8b932dd1789c3c5bc8defbf4807c7b4a74d3a55f..94b0ae7853a31c50adde2ca0827fedae3a6d66fe 100644 (file)
@@ -89,6 +89,9 @@ int main(int argc, char *argv[])
        if (my_args.quiet)
                quiet = true;
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
        if (!c) {
                if (!quiet)
@@ -278,4 +281,3 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
 
        return bret;
 }
-
index 28c33773f85223aa2c23e49b9ab460b41d4edadd..c28dc85ecc727496f25e8798849a172a05d87984 100644 (file)
@@ -127,6 +127,9 @@ int main(int argc, char *argv[])
                goto err;
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
        if (!c) {
                ERROR("%s doesn't exist", my_args.name);
index 234591c476d83b439f6535870ab6850deaaa10c0..a2d42dda72a0181debf0c40518b7a4f9ba8f892f 100644 (file)
@@ -136,6 +136,9 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
        if (!c) {
                ERROR("Failed to create lxc_container");
index 93b9df49c802dd4a379870510cf3ecaa7a679f94..c96ff892e7415dc5cb228244b58b6449824e3e93 100644 (file)
@@ -76,6 +76,9 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
        if (!c) {
                ERROR("No such container: %s:%s", my_args.lxcpath[0], my_args.name);
index cde4cb633efc07cd4d523dc0faf5b29cf12bf34d..b73a12b902e105b5fc8b5e481f206ac4f81c4ff0 100644 (file)
@@ -413,6 +413,9 @@ int main(int argc, char *argv[])
                exit(ret);
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        if (print_info(my_args.name, my_args.lxcpath[0]) == 0)
                ret = EXIT_SUCCESS;
 
index 21f8d9264dd5cbe4fd8bf52b54d5f06fbcb843e2..77493e9594cf87177606ad6008df2fbe9c39478a 100644 (file)
@@ -233,6 +233,9 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        struct lengths max_len = {
                /* default header length */
                .name_length = 4,      /* NAME */
index 7be26bf7c4b9d56964faab242375d7f5761d67bd..3e98f066b97d4becdf733079657f7f180b723f62 100644 (file)
@@ -113,6 +113,9 @@ int main(int argc, char *argv[])
                exit(rc_main);
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        if (quit_monitord) {
                int ret = EXIT_SUCCESS;
                for (i = 0; i < my_args.lxcpath_cnt; i++) {
index 82269ae387f6fc2f5ed7f1aee2f14956c932d808..0a97961e7e36f67eef59f666b8124a5d34d386c6 100644 (file)
@@ -101,6 +101,9 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        if (geteuid()) {
                if (access(my_args.lxcpath[0], O_RDONLY) < 0) {
                        fprintf(stderr, "You lack access to %s\n",
@@ -304,4 +307,3 @@ static void print_file(char *path)
        free(line);
        fclose(f);
 }
-
index d4653274572e8b590c291f1f9344a2b9afed5851..639248e0ea70cd79ac58816122be8fc3962b2a2c 100644 (file)
@@ -244,6 +244,9 @@ int main(int argc, char *argv[])
 
        const char *lxcpath = my_args.lxcpath[0];
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        /*
         * rcfile possibilities:
         * 1. rcfile from random path specified in cli option
index 0a17e25fd2f3e9ce6af6a98dd82048a862add50d..55674a2b3270219ce18f474587cc7d9b902d1b87 100644 (file)
@@ -173,6 +173,9 @@ int main(int argc, char *argv[])
                exit(ret);
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        /* Set default timeout */
        if (my_args.timeout == -2) {
                if (my_args.hardstop)
index 394fe0ee060f33f1d7cc0aae434199945a0ed441..2213374001cc17bff81b5d37c6ffd2a2d3a2a794 100644 (file)
@@ -75,6 +75,9 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
        if (!c) {
                ERROR("No such container: %s:%s", my_args.lxcpath[0], my_args.name);
index f3b5e067d456607a62072d4e8e86ad55b7741831..b922194053af92de7eaeae21d02f127a7d69d574 100644 (file)
@@ -102,6 +102,9 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        lxc_log_options_no_override();
 
+       /* REMOVE IN LXC 3.0 */
+       setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
+
        c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
        if (!c)
                exit(EXIT_FAILURE);