[lxc-devel] [PATCH 3/3] Let lxc-start read container name from rcfile if not specified on command line
Michael Holzt
lxc at my.fqdn.org
Sat Jan 9 02:35:59 UTC 2010
Let lxc-start read container name from rcfile if not specified on command
line.
Signed-off-by: Michael Holzt <lxc at my.fqdn.org>
---
src/lxc/lxc_start.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/src/lxc/lxc_start.c b/src/lxc/lxc_start.c
index fdd3b15..4b19a6a 100644
--- a/src/lxc/lxc_start.c
+++ b/src/lxc/lxc_start.c
@@ -50,6 +50,16 @@
lxc_log_define(lxc_start, lxc);
+static int my_checker(const struct lxc_arguments* args)
+{
+ if (!args->name && !args->rcfile) {
+ lxc_error(args, "neither container name nor configuration file specified");
+ return -1;
+ }
+
+ return 0;
+}
+
static int my_parser(struct lxc_arguments* args, int c, char* arg)
{
switch (c) {
@@ -78,7 +88,7 @@ Options :\n\
-f, --rcfile=FILE Load configuration file FILE\n",
.options = my_longopts,
.parser = my_parser,
- .checker = NULL,
+ .checker = my_checker,
.daemonize = 0,
};
@@ -174,6 +184,14 @@ int main(int argc, char *argv[])
return err;
}
+ if (!my_args.name) {
+ if (!conf->name) {
+ ERROR("container name not defined in configuration file and not set on cmdline");
+ return err;
+ }
+ my_args.name = conf->name;
+ }
+
if (!rcfile && !strcmp("/sbin/init", args[0])) {
ERROR("no configuration file for '/sbin/init' (may crash the host)");
return err;
--
1.6.5
More information about the lxc-devel
mailing list