From: Stéphane Graber Date: Fri, 7 Mar 2014 20:29:12 +0000 (-0500) Subject: lxc-create: Require --template be passed X-Git-Tag: lxc-1.1.0.alpha1~226 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3de16bb56b418884b41c50a4d15543129b5a564;p=thirdparty%2Flxc.git lxc-create: Require --template be passed 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 Acked-by: Serge E. Hallyn --- diff --git a/doc/lxc-create.sgml.in b/doc/lxc-create.sgml.in index 03643c5e5..1c17c1aab 100644 --- a/doc/lxc-create.sgml.in +++ b/doc/lxc-create.sgml.in @@ -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. diff --git a/src/lxc/lxc_create.c b/src/lxc/lxc_create.c index eee6ffd79..6b595f986 100644 --- a/src/lxc/lxc_create.c +++ b/src/lxc/lxc_create.c @@ -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";