Commit d3de16bb by Stéphane Graber

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: 's avatarStéphane Graber <stgraber@ubuntu.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 9ec38a6d
......@@ -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>
......
......@@ -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";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment