]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Revert "api: ->save_config() doesn't need to create container dir"
authorStéphane Graber <stgraber@ubuntu.com>
Tue, 30 Nov 2021 22:39:34 +0000 (17:39 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 30 Nov 2021 22:39:34 +0000 (17:39 -0500)
This reverts commit 2fde07c3990fe09925699da5d9a1762eb279c497.

We need to investigate this in more detail but this commit is breaking
LXD, causing startup to fail with:

lxc foo 20211130202833.906 INFO     conf - conf.c:run_script_argv:336 - Executing script "/bin/mount -t shiftfs -o passthrough=3 "/lxc-ci/build/tmp.WemmpzWGYz/go/src/github.com/lxc/lxd/test/tmp.Cli/0To/containers/foo/rootfs" "/lxc-ci/build/tmp.WemmpzWGYz/go/src/github.com/lxc/lxd/test/tmp.Cli/0To/containers/foo/rootfs"" for container "foo"
lxc foo 20211130202833.912 ERROR    conf - conf.c:run_buffer:321 - Script exited with status 32
lxc foo 20211130202833.912 ERROR    conf - conf.c:lxc_setup_rootfs_prepare_root:3947 - Failed to run pre-mount hooks
lxc foo 20211130202833.912 ERROR    conf - conf.c:lxc_setup:4317 - Failed to setup rootfs
lxc foo 20211130202833.912 ERROR    start - start.c:do_start:1275 - Failed to setup container "foo"

Not entirely sure why we're seeing things blow up as the directory
definitely exists (and contains a valid rootfs) but this was caused by
today's liblxc update.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/lxccontainer.c

index b83264f7ca30b8d48cebaad34af337685a531c4f..96fdb3fd22db68077946e500adca877ada334b08 100644 (file)
@@ -2608,6 +2608,12 @@ static bool do_lxcapi_save_config(struct lxc_container *c, const char *alt_file)
        int fd, lret;
        bool ret = false, need_disklock = false;
 
+       if (!alt_file)
+               alt_file = c->configfile;
+
+       if (!alt_file)
+               return false;
+
        /* If we haven't yet loaded a config, load the stock config. */
        if (!c->lxc_conf) {
                if (!do_lxcapi_load_config(c, lxc_global_config_value("lxc.default_config"))) {
@@ -2619,13 +2625,7 @@ static bool do_lxcapi_save_config(struct lxc_container *c, const char *alt_file)
                }
        }
 
-       if (!alt_file) {
-               alt_file = c->configfile;
-               if (!create_container_dir(c))
-                       return false;
-       }
-
-       if (!alt_file)
+       if (!create_container_dir(c))
                return false;
 
        /* If we're writing to the container's config file, take the disk lock.