]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-create: Require --template be passed
authorStéphane Graber <stgraber@ubuntu.com>
Fri, 7 Mar 2014 20:29:12 +0000 (15:29 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 6 Nov 2015 18:35:26 +0000 (13:35 -0500)
It's often been reported that the behavior of lxc-create without -t is a
bit confusing. This change makes lxc-create require the --template
option and introduces a new "none" special value which when set will
fallback to the old template-less behavior.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
doc/lxc-create.sgml.in
src/lxc/lxc_create.c

index 9089da6aba15420e9bd091ac929dd3e93bb7a6d8..053fa0f52b2d907a806fbdb5943a646ba90db893 100644 (file)
@@ -115,6 +115,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
            for details of the expected script structure.
            Alternatively, the full path to an executable template script
            can also be passed as a parameter.
+           "none" can be used to force lxc-create to skip rootfs creation.
          </para>
        </listitem>
       </varlistentry>
index 652fa3f548a929c53bf9086cf8399ff80cf5b773..f1094fba8fa73639c4c94e2754e7e8f364ee1f85 100644 (file)
@@ -126,7 +126,7 @@ static struct lxc_arguments my_args = {
        .progname = "lxc-create",
        .helpfn   = create_helpfn,
        .help     = "\
---name=NAME [-w] [-r] [-t template] [-P lxcpath]\n\
+--name=NAME -t template [-w] [-r] [-P lxcpath]\n\
 \n\
 lxc-create creates a container\n\
 \n\
@@ -197,6 +197,15 @@ int main(int argc, char *argv[])
                exit(1);
        lxc_log_options_no_override();
 
+       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");
+               exit(1);
+       }
+
+       if (strcmp(my_args.template, "none") == 0)
+               my_args.template = NULL;
+
        memset(&spec, 0, sizeof(spec));
        if (!my_args.bdevtype)
                my_args.bdevtype = "_unset";