]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Fix container creation without a rootfs
authorDavid Ward <david.ward@ll.mit.edu>
Tue, 23 Jun 2015 14:57:25 +0000 (10:57 -0400)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 27 Aug 2015 21:36:54 +0000 (16:36 -0500)
It is not an error to create a container without a template or rootfs.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxccontainer.c

index 45b1798ecb0751c57445e8ae0728e4e21e995d1f..ce2ec8aea6dcf1d7eee2befa3289bc9e04523519 100644 (file)
@@ -1365,13 +1365,18 @@ static bool do_lxcapi_create(struct lxc_container *c, const char *t,
                goto free_tpath;
 
        /*
-        * either template or rootfs.path should be set.
         * if both template and rootfs.path are set, template is setup as rootfs.path.
         * container is already created if we have a config and rootfs.path is accessible
         */
-       if (!c->lxc_conf->rootfs.path && !tpath)
-               /* no template passed in and rootfs does not exist: error */
+       if (!c->lxc_conf->rootfs.path && !tpath) {
+               /* no template passed in and rootfs does not exist */
+               if (!c->save_config(c, NULL)) {
+                       ERROR("failed to save starting configuration for %s\n", c->name);
+                       goto out;
+               }
+               ret = true;
                goto out;
+       }
        if (c->lxc_conf->rootfs.path && access(c->lxc_conf->rootfs.path, F_OK) != 0)
                /* rootfs passed into configuration, but does not exist: error */
                goto out;