]> 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, 7 Mar 2014 22:18:51 +0000 (17:18 -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 03643c5e562372fa3e4642a99a4d35f357384d4b..1c17c1aab3151fbb6663bd042da64df64c184cd8 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 eee6ffd7984b624b576fb0dc4eedd7a087ab6a15..6b595f986b156c0cd0b6e3e1f7a1f1d379ad5e01 100644 (file)
@@ -132,7 +132,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\
@@ -203,6 +203,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";