From 50b737a3c6d0b93d4c4264c8364e61f578256499 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 12 Aug 2016 12:21:22 +0200 Subject: [PATCH 1/6] tools: move --rcfile to the common options list In almost all commands it's a useful addition to the -n switch which is a common option, too. Signed-off-by: Wolfgang Bumiller --- src/lxc/arguments.c | 1 + src/lxc/arguments.h | 2 ++ src/lxc/tools/lxc_cgroup.c | 12 +++++++++++- src/lxc/tools/lxc_checkpoint.c | 10 ++++++++++ src/lxc/tools/lxc_console.c | 12 +++++++++++- src/lxc/tools/lxc_copy.c | 11 ++++++++++- src/lxc/tools/lxc_destroy.c | 12 +++++++++++- src/lxc/tools/lxc_device.c | 11 ++++++++++- src/lxc/tools/lxc_freeze.c | 12 +++++++++++- src/lxc/tools/lxc_info.c | 12 +++++++++++- src/lxc/tools/lxc_snapshot.c | 12 +++++++++++- src/lxc/tools/lxc_stop.c | 11 ++++++++++- src/lxc/tools/lxc_unfreeze.c | 12 +++++++++++- src/lxc/tools/lxc_wait.c | 12 +++++++++++- 14 files changed, 131 insertions(+), 11 deletions(-) diff --git a/src/lxc/arguments.c b/src/lxc/arguments.c index c2f7b67a6..0d2b2031b 100644 --- a/src/lxc/arguments.c +++ b/src/lxc/arguments.c @@ -203,6 +203,7 @@ extern int lxc_arguments_parse(struct lxc_arguments *args, case 'o': args->log_file = optarg; break; case 'l': args->log_priority = optarg; break; case 'q': args->quiet = 1; break; + case OPT_RCFILE: args->rcfile = optarg; break; case 'P': remove_trailing_slashes(optarg); ret = lxc_arguments_lxcpath_add(args, optarg); diff --git a/src/lxc/arguments.h b/src/lxc/arguments.h index f68f8ab90..39bedf566 100644 --- a/src/lxc/arguments.h +++ b/src/lxc/arguments.h @@ -151,11 +151,13 @@ struct lxc_arguments { {"logfile", required_argument, 0, 'o'}, \ {"logpriority", required_argument, 0, 'l'}, \ {"lxcpath", required_argument, 0, 'P'}, \ + {"rcfile", required_argument, 0, OPT_RCFILE}, \ {0, 0, 0, 0} /* option keys for long only options */ #define OPT_USAGE 0x1000 #define OPT_VERSION OPT_USAGE-1 +#define OPT_RCFILE OPT_USAGE-2 extern int lxc_arguments_parse(struct lxc_arguments *args, int argc, char *const argv[]); diff --git a/src/lxc/tools/lxc_cgroup.c b/src/lxc/tools/lxc_cgroup.c index dd60fd107..c64450173 100644 --- a/src/lxc/tools/lxc_cgroup.c +++ b/src/lxc/tools/lxc_cgroup.c @@ -56,7 +56,8 @@ Get or set the value of a state object (for example, 'cpuset.cpus')\n\ in the container's cgroup for the corresponding subsystem.\n\ \n\ Options :\n\ - -n, --name=NAME NAME of the container", + -n, --name=NAME NAME of the container\n\ + --rcfile=FILE Load configuration file FILE\n", .options = my_longopts, .parser = NULL, .checker = my_checker, @@ -84,6 +85,15 @@ int main(int argc, char *argv[]) if (!c) return 1; + if (my_args.rcfile) { + c->clear_config(c); + if (!c->load_config(c, my_args.rcfile)) { + ERROR("Failed to load rcfile"); + lxc_container_put(c); + return 1; + } + } + if (!c->may_control(c)) { ERROR("Insufficent privileges to control %s:%s", my_args.lxcpath[0], my_args.name); lxc_container_put(c); diff --git a/src/lxc/tools/lxc_checkpoint.c b/src/lxc/tools/lxc_checkpoint.c index 7130245a7..bc18b80c9 100644 --- a/src/lxc/tools/lxc_checkpoint.c +++ b/src/lxc/tools/lxc_checkpoint.c @@ -114,6 +114,7 @@ Options :\n\ Restore options:\n\ -d, --daemon Daemonize the container (default)\n\ -F, --foreground Start with the current tty attached to /dev/console\n\ + --rcfile=FILE Load configuration file FILE\n\ ", .options = my_longopts, .parser = my_parser, @@ -214,6 +215,15 @@ int main(int argc, char *argv[]) exit(1); } + if (my_args.rcfile) { + c->clear_config(c); + if (!c->load_config(c, my_args.rcfile)) { + fprintf(stderr, "Failed to load rcfile\n"); + lxc_container_put(c); + exit(1); + } + } + if (!c->may_control(c)) { fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name); lxc_container_put(c); diff --git a/src/lxc/tools/lxc_console.c b/src/lxc/tools/lxc_console.c index adbd7e019..8a4d1c0f9 100644 --- a/src/lxc/tools/lxc_console.c +++ b/src/lxc/tools/lxc_console.c @@ -80,7 +80,8 @@ lxc-console logs on the container with the identifier NAME\n\ Options :\n\ -n, --name=NAME NAME of the container\n\ -t, --tty=NUMBER console tty number\n\ - -e, --escape=PREFIX prefix for escape command\n", + -e, --escape=PREFIX prefix for escape command\n\ + --rcfile=FILE Load configuration file FILE\n", .options = my_longopts, .parser = my_parser, .checker = NULL, @@ -112,6 +113,15 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } + if (my_args.rcfile) { + c->clear_config(c); + if (!c->load_config(c, my_args.rcfile)) { + fprintf(stderr, "Failed to load rcfile\n"); + lxc_container_put(c); + exit(EXIT_FAILURE); + } + } + if (!c->may_control(c)) { fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name); lxc_container_put(c); diff --git a/src/lxc/tools/lxc_copy.c b/src/lxc/tools/lxc_copy.c index 3257ab73b..c81c07770 100644 --- a/src/lxc/tools/lxc_copy.c +++ b/src/lxc/tools/lxc_copy.c @@ -126,7 +126,8 @@ Options :\n\ -D, --keedata pass together with -e start a persistent snapshot \n\ -K, --keepname keep the hostname of the original container\n\ -- hook options arguments passed to the hook program\n\ - -M, --keepmac keep the MAC address of the original container\n", + -M, --keepmac keep the MAC address of the original container\n\ + --rcfile=FILE Load configuration file FILE\n", .options = my_longopts, .parser = my_parser, .task = CLONE, @@ -210,6 +211,14 @@ int main(int argc, char *argv[]) if (!c) exit(ret); + if (my_args.rcfile) { + c->clear_config(c); + if (!c->load_config(c, my_args.rcfile)) { + fprintf(stderr, "Failed to load rcfile\n"); + goto out; + } + } + if (!c->may_control(c)) { if (!my_args.quiet) fprintf(stderr, "Insufficent privileges to control %s\n", c->name); diff --git a/src/lxc/tools/lxc_destroy.c b/src/lxc/tools/lxc_destroy.c index b521739be..50fd708a1 100644 --- a/src/lxc/tools/lxc_destroy.c +++ b/src/lxc/tools/lxc_destroy.c @@ -53,7 +53,8 @@ lxc-destroy destroys a container with the identifier NAME\n\ Options :\n\ -n, --name=NAME NAME of the container\n\ -s, --snapshots destroy including all snapshots\n\ - -f, --force wait for the container to shut down\n", + -f, --force wait for the container to shut down\n\ + --rcfile=FILE Load configuration file FILE\n", .options = my_longopts, .parser = my_parser, .checker = NULL, @@ -88,6 +89,15 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } + if (my_args.rcfile) { + c->clear_config(c); + if (!c->load_config(c, my_args.rcfile)) { + fprintf(stderr, "Failed to load rcfile\n"); + lxc_container_put(c); + exit(EXIT_FAILURE); + } + } + if (!c->may_control(c)) { if (!quiet) fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name); diff --git a/src/lxc/tools/lxc_device.c b/src/lxc/tools/lxc_device.c index 0c9e06648..0f1ee8b15 100644 --- a/src/lxc/tools/lxc_device.c +++ b/src/lxc/tools/lxc_device.c @@ -53,7 +53,8 @@ static struct lxc_arguments my_args = { lxc-device attach or detach DEV to or from container.\n\ \n\ Options :\n\ - -n, --name=NAME NAME of the container", + -n, --name=NAME NAME of the container\n\ + --rcfile=FILE Load configuration file FILE\n", .options = my_longopts, .parser = NULL, .checker = NULL, @@ -125,6 +126,14 @@ int main(int argc, char *argv[]) goto err; } + if (my_args.rcfile) { + c->clear_config(c); + if (!c->load_config(c, my_args.rcfile)) { + ERROR("Failed to load rcfile"); + goto err1; + } + } + if (!c->is_running(c)) { ERROR("Container %s is not running.", c->name); goto err1; diff --git a/src/lxc/tools/lxc_freeze.c b/src/lxc/tools/lxc_freeze.c index ea8bd3eae..d0239bfea 100644 --- a/src/lxc/tools/lxc_freeze.c +++ b/src/lxc/tools/lxc_freeze.c @@ -47,7 +47,8 @@ static struct lxc_arguments my_args = { lxc-freeze freezes a container with the identifier NAME\n\ \n\ Options :\n\ - -n, --name=NAME NAME of the container", + -n, --name=NAME NAME of the container\n\ + --rcfile=FILE Load configuration file FILE\n", .options = my_longopts, .parser = NULL, .checker = NULL, @@ -74,6 +75,15 @@ int main(int argc, char *argv[]) exit(1); } + if (my_args.rcfile) { + c->clear_config(c); + if (!c->load_config(c, my_args.rcfile)) { + ERROR("Failed to load rcfile"); + lxc_container_put(c); + exit(1); + } + } + if (!c->may_control(c)) { ERROR("Insufficent privileges to control %s:%s", my_args.lxcpath[0], my_args.name); lxc_container_put(c); diff --git a/src/lxc/tools/lxc_info.c b/src/lxc/tools/lxc_info.c index 58ff619f2..e83369707 100644 --- a/src/lxc/tools/lxc_info.c +++ b/src/lxc/tools/lxc_info.c @@ -93,7 +93,8 @@ Options :\n\ -p, --pid shows the process id of the init container\n\ -S, --stats shows usage stats\n\ -H, --no-humanize shows stats as raw numbers, not humanized\n\ - -s, --state shows the state of the container\n", + -s, --state shows the state of the container\n\ + --rcfile=FILE Load configuration file FILE\n", .name = NULL, .options = my_longopts, .parser = my_parser, @@ -295,6 +296,15 @@ static int print_info(const char *name, const char *lxcpath) return -1; } + if (my_args.rcfile) { + c->clear_config(c); + if (!c->load_config(c, my_args.rcfile)) { + fprintf(stderr, "Failed to load rcfile\n"); + lxc_container_put(c); + return -1; + } + } + if (!c->may_control(c)) { fprintf(stderr, "Insufficent privileges to control %s\n", c->name); lxc_container_put(c); diff --git a/src/lxc/tools/lxc_snapshot.c b/src/lxc/tools/lxc_snapshot.c index 8f44891b5..aa9b6fec1 100644 --- a/src/lxc/tools/lxc_snapshot.c +++ b/src/lxc/tools/lxc_snapshot.c @@ -62,7 +62,8 @@ Options :\n\ -d, --destroy=NAME destroy snapshot NAME, e.g. 'snap0'\n\ use ALL to destroy all snapshots\n\ -c, --comment=FILE add FILE as a comment\n\ - -C, --showcomments show snapshot comments\n", + -C, --showcomments show snapshot comments\n\ + --rcfile=FILE Load configuration file FILE\n", .options = my_longopts, .parser = my_parser, .checker = NULL, @@ -107,6 +108,15 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } + if (my_args.rcfile) { + c->clear_config(c); + if (!c->load_config(c, my_args.rcfile)) { + fprintf(stderr, "Failed to load rcfile\n"); + lxc_container_put(c); + exit(EXIT_FAILURE); + } + } + if (!c->may_control(c)) { fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name); diff --git a/src/lxc/tools/lxc_stop.c b/src/lxc/tools/lxc_stop.c index 10ddce6a9..bbe1f1c61 100644 --- a/src/lxc/tools/lxc_stop.c +++ b/src/lxc/tools/lxc_stop.c @@ -75,7 +75,8 @@ Options :\n\ -t, --timeout=T wait T seconds before hard-stopping\n\ -k, --kill kill container rather than request clean shutdown\n\ --nolock Avoid using API locks\n\ - --nokill Only request clean shutdown, don't force kill after timeout\n", + --nokill Only request clean shutdown, don't force kill after timeout\n\ + --rcfile=FILE Load configuration file FILE\n", .options = my_longopts, .parser = my_parser, .checker = NULL, @@ -203,6 +204,14 @@ int main(int argc, char *argv[]) goto out; } + if (my_args.rcfile) { + c->clear_config(c); + if (!c->load_config(c, my_args.rcfile)) { + fprintf(stderr, "Failed to load rcfile\n"); + goto out; + } + } + if (!c->may_control(c)) { fprintf(stderr, "Insufficent privileges to control %s\n", c->name); goto out; diff --git a/src/lxc/tools/lxc_unfreeze.c b/src/lxc/tools/lxc_unfreeze.c index 3a13d3723..b7bbea686 100644 --- a/src/lxc/tools/lxc_unfreeze.c +++ b/src/lxc/tools/lxc_unfreeze.c @@ -45,7 +45,8 @@ static struct lxc_arguments my_args = { lxc-unfreeze unfreezes a container with the identifier NAME\n\ \n\ Options :\n\ - -n, --name=NAME NAME of the container\n", + -n, --name=NAME NAME of the container\n\ + --rcfile=FILE Load configuration file FILE\n", .options = my_longopts, .parser = NULL, .checker = NULL, @@ -78,6 +79,15 @@ int main(int argc, char *argv[]) exit(1); } + if (my_args.rcfile) { + c->clear_config(c); + if (!c->load_config(c, my_args.rcfile)) { + ERROR("Failed to load rcfile"); + lxc_container_put(c); + exit(1); + } + } + if (!c->unfreeze(c)) { ERROR("Failed to unfreeze %s:%s", my_args.lxcpath[0], my_args.name); lxc_container_put(c); diff --git a/src/lxc/tools/lxc_wait.c b/src/lxc/tools/lxc_wait.c index 712ba52d6..deeff984b 100644 --- a/src/lxc/tools/lxc_wait.c +++ b/src/lxc/tools/lxc_wait.c @@ -72,7 +72,8 @@ Options :\n\ -s, --state=STATE ORed states to wait for\n\ STOPPED, STARTING, RUNNING, STOPPING,\n\ ABORTING, FREEZING, FROZEN, THAWED\n\ - -t, --timeout=TMO Seconds to wait for state changes\n", + -t, --timeout=TMO Seconds to wait for state changes\n\ + --rcfile=FILE Load configuration file FILE\n", .options = my_longopts, .parser = my_parser, .checker = my_checker, @@ -104,6 +105,15 @@ int main(int argc, char *argv[]) return 1; } + if (my_args.rcfile) { + c->clear_config(c); + if (!c->load_config(c, my_args.rcfile)) { + fprintf(stderr, "Failed to load rcfile\n"); + lxc_container_put(c); + return 1; + } + } + if (!c->wait(c, my_args.states, my_args.timeout)) { lxc_container_put(c); return 1; From 6118210e0afd4ed4abb1d9639f1aed7e005a2830 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 12 Aug 2016 14:49:37 +0200 Subject: [PATCH 2/6] tools: set configfile after load_config In order to cause c->is_defined() to become true. Signed-off-by: Wolfgang Bumiller --- src/lxc/tools/lxc_attach.c | 6 ++++++ src/lxc/tools/lxc_cgroup.c | 6 ++++++ src/lxc/tools/lxc_checkpoint.c | 6 ++++++ src/lxc/tools/lxc_console.c | 6 ++++++ src/lxc/tools/lxc_copy.c | 5 +++++ src/lxc/tools/lxc_destroy.c | 6 ++++++ src/lxc/tools/lxc_device.c | 5 +++++ src/lxc/tools/lxc_freeze.c | 6 ++++++ src/lxc/tools/lxc_info.c | 6 ++++++ src/lxc/tools/lxc_snapshot.c | 6 ++++++ src/lxc/tools/lxc_stop.c | 5 +++++ src/lxc/tools/lxc_unfreeze.c | 6 ++++++ src/lxc/tools/lxc_wait.c | 6 ++++++ 13 files changed, 75 insertions(+) diff --git a/src/lxc/tools/lxc_attach.c b/src/lxc/tools/lxc_attach.c index 281f97aca..9d7138835 100644 --- a/src/lxc/tools/lxc_attach.c +++ b/src/lxc/tools/lxc_attach.c @@ -385,6 +385,12 @@ int main(int argc, char *argv[]) lxc_container_put(c); exit(EXIT_FAILURE); } + c->configfile = strdup(my_args.rcfile); + if (!c->configfile) { + ERROR("Out of memory setting new config filename"); + lxc_container_put(c); + exit(EXIT_FAILURE); + } } if (!c->may_control(c)) { diff --git a/src/lxc/tools/lxc_cgroup.c b/src/lxc/tools/lxc_cgroup.c index c64450173..4dc2682b8 100644 --- a/src/lxc/tools/lxc_cgroup.c +++ b/src/lxc/tools/lxc_cgroup.c @@ -92,6 +92,12 @@ int main(int argc, char *argv[]) lxc_container_put(c); return 1; } + c->configfile = strdup(my_args.rcfile); + if (!c->configfile) { + ERROR("Out of memory setting new config filename"); + lxc_container_put(c); + return 1; + } } if (!c->may_control(c)) { diff --git a/src/lxc/tools/lxc_checkpoint.c b/src/lxc/tools/lxc_checkpoint.c index bc18b80c9..6de3d239b 100644 --- a/src/lxc/tools/lxc_checkpoint.c +++ b/src/lxc/tools/lxc_checkpoint.c @@ -222,6 +222,12 @@ int main(int argc, char *argv[]) lxc_container_put(c); exit(1); } + c->configfile = strdup(my_args.rcfile); + if (!c->configfile) { + fprintf(stderr, "Out of memory setting new config filename\n"); + lxc_container_put(c); + exit(1); + } } if (!c->may_control(c)) { diff --git a/src/lxc/tools/lxc_console.c b/src/lxc/tools/lxc_console.c index 8a4d1c0f9..829c908d4 100644 --- a/src/lxc/tools/lxc_console.c +++ b/src/lxc/tools/lxc_console.c @@ -120,6 +120,12 @@ int main(int argc, char *argv[]) lxc_container_put(c); exit(EXIT_FAILURE); } + c->configfile = strdup(my_args.rcfile); + if (!c->configfile) { + fprintf(stderr, "Out of memory setting new config filename\n"); + lxc_container_put(c); + exit(EXIT_FAILURE); + } } if (!c->may_control(c)) { diff --git a/src/lxc/tools/lxc_copy.c b/src/lxc/tools/lxc_copy.c index c81c07770..f7dc8b29d 100644 --- a/src/lxc/tools/lxc_copy.c +++ b/src/lxc/tools/lxc_copy.c @@ -217,6 +217,11 @@ int main(int argc, char *argv[]) fprintf(stderr, "Failed to load rcfile\n"); goto out; } + c->configfile = strdup(my_args.rcfile); + if (!c->configfile) { + fprintf(stderr, "Out of memory setting new config filename\n"); + goto out; + } } if (!c->may_control(c)) { diff --git a/src/lxc/tools/lxc_destroy.c b/src/lxc/tools/lxc_destroy.c index 50fd708a1..3f46415df 100644 --- a/src/lxc/tools/lxc_destroy.c +++ b/src/lxc/tools/lxc_destroy.c @@ -96,6 +96,12 @@ int main(int argc, char *argv[]) lxc_container_put(c); exit(EXIT_FAILURE); } + c->configfile = strdup(my_args.rcfile); + if (!c->configfile) { + fprintf(stderr, "Out of memory setting new config filename\n"); + lxc_container_put(c); + exit(EXIT_FAILURE); + } } if (!c->may_control(c)) { diff --git a/src/lxc/tools/lxc_device.c b/src/lxc/tools/lxc_device.c index 0f1ee8b15..49af062e5 100644 --- a/src/lxc/tools/lxc_device.c +++ b/src/lxc/tools/lxc_device.c @@ -132,6 +132,11 @@ int main(int argc, char *argv[]) ERROR("Failed to load rcfile"); goto err1; } + c->configfile = strdup(my_args.rcfile); + if (!c->configfile) { + ERROR("Out of memory setting new config filename"); + goto err1; + } } if (!c->is_running(c)) { diff --git a/src/lxc/tools/lxc_freeze.c b/src/lxc/tools/lxc_freeze.c index d0239bfea..ac0802e5a 100644 --- a/src/lxc/tools/lxc_freeze.c +++ b/src/lxc/tools/lxc_freeze.c @@ -82,6 +82,12 @@ int main(int argc, char *argv[]) lxc_container_put(c); exit(1); } + c->configfile = strdup(my_args.rcfile); + if (!c->configfile) { + ERROR("Out of memory setting new config filename"); + lxc_container_put(c); + exit(1); + } } if (!c->may_control(c)) { diff --git a/src/lxc/tools/lxc_info.c b/src/lxc/tools/lxc_info.c index e83369707..08c698d61 100644 --- a/src/lxc/tools/lxc_info.c +++ b/src/lxc/tools/lxc_info.c @@ -303,6 +303,12 @@ static int print_info(const char *name, const char *lxcpath) lxc_container_put(c); return -1; } + c->configfile = strdup(my_args.rcfile); + if (!c->configfile) { + fprintf(stderr, "Out of memory setting new config filename\n"); + lxc_container_put(c); + return -1; + } } if (!c->may_control(c)) { diff --git a/src/lxc/tools/lxc_snapshot.c b/src/lxc/tools/lxc_snapshot.c index aa9b6fec1..a1166bcbc 100644 --- a/src/lxc/tools/lxc_snapshot.c +++ b/src/lxc/tools/lxc_snapshot.c @@ -115,6 +115,12 @@ int main(int argc, char *argv[]) lxc_container_put(c); exit(EXIT_FAILURE); } + c->configfile = strdup(my_args.rcfile); + if (!c->configfile) { + fprintf(stderr, "Out of memory setting new config filename\n"); + lxc_container_put(c); + exit(EXIT_FAILURE); + } } if (!c->may_control(c)) { diff --git a/src/lxc/tools/lxc_stop.c b/src/lxc/tools/lxc_stop.c index bbe1f1c61..cb7cfe2e6 100644 --- a/src/lxc/tools/lxc_stop.c +++ b/src/lxc/tools/lxc_stop.c @@ -210,6 +210,11 @@ int main(int argc, char *argv[]) fprintf(stderr, "Failed to load rcfile\n"); goto out; } + c->configfile = strdup(my_args.rcfile); + if (!c->configfile) { + fprintf(stderr, "Out of memory setting new config filename\n"); + goto out; + } } if (!c->may_control(c)) { diff --git a/src/lxc/tools/lxc_unfreeze.c b/src/lxc/tools/lxc_unfreeze.c index b7bbea686..24faf5e96 100644 --- a/src/lxc/tools/lxc_unfreeze.c +++ b/src/lxc/tools/lxc_unfreeze.c @@ -86,6 +86,12 @@ int main(int argc, char *argv[]) lxc_container_put(c); exit(1); } + c->configfile = strdup(my_args.rcfile); + if (!c->configfile) { + ERROR("Out of memory setting new config filename"); + lxc_container_put(c); + exit(1); + } } if (!c->unfreeze(c)) { diff --git a/src/lxc/tools/lxc_wait.c b/src/lxc/tools/lxc_wait.c index deeff984b..61fd869d7 100644 --- a/src/lxc/tools/lxc_wait.c +++ b/src/lxc/tools/lxc_wait.c @@ -112,6 +112,12 @@ int main(int argc, char *argv[]) lxc_container_put(c); return 1; } + c->configfile = strdup(my_args.rcfile); + if (!c->configfile) { + fprintf(stderr, "Out of memory setting new config filename\n"); + lxc_container_put(c); + return 1; + } } if (!c->wait(c, my_args.states, my_args.timeout)) { From 71d74a8342ead4300c7f21e40d84edfb27a073e9 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 12 Aug 2016 14:55:42 +0200 Subject: [PATCH 3/6] doc: add --rcfile to common opts Signed-off-by: Wolfgang Bumiller --- doc/common_options.sgml.in | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/common_options.sgml.in b/doc/common_options.sgml.in index 38783dd1e..978c0ba0d 100644 --- a/doc/common_options.sgml.in +++ b/doc/common_options.sgml.in @@ -106,6 +106,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + + + + Specify the configuration file to configure the virtualization + and isolation functionalities for the container. + + + This configuration file if present will be used even if there is + already a configuration file present in the previously created + container (via lxc-create). + + + + From 8564baf99a43b3c33857e6daafcad8370e2e374a Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 12 Aug 2016 12:28:16 +0200 Subject: [PATCH 4/6] cleanup: tools: remove --name from lxc-top usage message It doesn't have any effect on what lxc-top does and is only accepted on account of being part of the common option list. Signed-off-by: Wolfgang Bumiller --- src/lxc/tools/lxc_top.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lxc/tools/lxc_top.c b/src/lxc/tools/lxc_top.c index c4cb87168..47deddd62 100644 --- a/src/lxc/tools/lxc_top.c +++ b/src/lxc/tools/lxc_top.c @@ -91,7 +91,7 @@ static const struct option my_longopts[] = { static struct lxc_arguments my_args = { .progname = "lxc-top", .help = "\ -[--name=NAME]\n\ +\n\ \n\ lxc-top monitors the state of the active containers\n\ \n\ From 7665872377a5b79c232d54bc2b7c77c77fb76e36 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 12 Aug 2016 12:33:10 +0200 Subject: [PATCH 5/6] cleanup: whitespaces in option alignment for lxc-execute Signed-off-by: Wolfgang Bumiller --- src/lxc/tools/lxc_execute.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lxc/tools/lxc_execute.c b/src/lxc/tools/lxc_execute.c index 50d481f0e..c7c50962c 100644 --- a/src/lxc/tools/lxc_execute.c +++ b/src/lxc/tools/lxc_execute.c @@ -86,8 +86,8 @@ Options :\n\ -n, --name=NAME NAME of the container\n\ -f, --rcfile=FILE Load configuration file FILE\n\ -s, --define KEY=VAL Assign VAL to configuration variable KEY\n\ - -u, --uid=UID Execute COMMAND with UID inside the container\n\ - -g, --gid=GID Execute COMMAND with GID inside the container\n", + -u, --uid=UID Execute COMMAND with UID inside the container\n\ + -g, --gid=GID Execute COMMAND with GID inside the container\n", .options = my_longopts, .parser = my_parser, .checker = my_checker, From 6f94152de5d3b28e86e67b8fcf1415f9c051ece1 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 12 Aug 2016 12:33:44 +0200 Subject: [PATCH 6/6] cleanup: replace tabs wth spaces in usage strings Signed-off-by: Wolfgang Bumiller --- src/lxc/tools/lxc_copy.c | 30 +++++++++++++++--------------- src/lxc/tools/lxc_ls.c | 4 ++-- src/lxc/tools/lxc_snapshot.c | 2 +- src/lxc/tools/lxc_usernsexec.c | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/lxc/tools/lxc_copy.c b/src/lxc/tools/lxc_copy.c index f7dc8b29d..80cfb27c0 100644 --- a/src/lxc/tools/lxc_copy.c +++ b/src/lxc/tools/lxc_copy.c @@ -112,22 +112,22 @@ Options :\n\ -n, --name=NAME NAME of the container\n\ -N, --newname=NEWNAME NEWNAME for the restored container\n\ -p, --newpath=NEWPATH NEWPATH for the container to be stored\n\ - -R, --rename rename container\n\ - -s, --snapshot create snapshot instead of clone\n\ - -F, --foreground start with current tty attached to /dev/console\n\ - -d, --daemon daemonize the container (default)\n\ - -e, --ephemeral start ephemeral container\n\ - -m, --mount directory to mount into container, either \n\ - {bind,aufs,overlay}=/src-path or {bind,aufs,overlay}=/src-path:/dst-path\n\ + -R, --rename rename container\n\ + -s, --snapshot create snapshot instead of clone\n\ + -F, --foreground start with current tty attached to /dev/console\n\ + -d, --daemon daemonize the container (default)\n\ + -e, --ephemeral start ephemeral container\n\ + -m, --mount directory to mount into container, either \n\ + {bind,aufs,overlay}=/src-path or {bind,aufs,overlay}=/src-path:/dst-path\n\ -B, --backingstorage=TYPE backingstorage type for the container\n\ - -t, --tmpfs place ephemeral container on a tmpfs\n\ - (WARNING: On reboot all changes made to the container will be lost.)\n\ - -L, --fssize size of the new block device for block device containers\n\ - -D, --keedata pass together with -e start a persistent snapshot \n\ - -K, --keepname keep the hostname of the original container\n\ - -- hook options arguments passed to the hook program\n\ - -M, --keepmac keep the MAC address of the original container\n\ - --rcfile=FILE Load configuration file FILE\n", + -t, --tmpfs place ephemeral container on a tmpfs\n\ + (WARNING: On reboot all changes made to the container will be lost.)\n\ + -L, --fssize size of the new block device for block device containers\n\ + -D, --keedata pass together with -e start a persistent snapshot \n\ + -K, --keepname keep the hostname of the original container\n\ + -- hook options arguments passed to the hook program\n\ + -M, --keepmac keep the MAC address of the original container\n\ + --rcfile=FILE Load configuration file FILE\n", .options = my_longopts, .parser = my_parser, .task = CLONE, diff --git a/src/lxc/tools/lxc_ls.c b/src/lxc/tools/lxc_ls.c index 0575277ca..e22c715ea 100644 --- a/src/lxc/tools/lxc_ls.c +++ b/src/lxc/tools/lxc_ls.c @@ -184,8 +184,8 @@ static struct lxc_arguments my_args = { lxc-ls list containers\n\ \n\ Options :\n\ - -1, --line show one entry per line\n\ - -f, --fancy column-based output\n\ + -1, --line show one entry per line\n\ + -f, --fancy column-based output\n\ -F, --fancy-format column-based output\n\ --active list only active containers\n\ --running list only running containers\n\ diff --git a/src/lxc/tools/lxc_snapshot.c b/src/lxc/tools/lxc_snapshot.c index a1166bcbc..1a79a7a1d 100644 --- a/src/lxc/tools/lxc_snapshot.c +++ b/src/lxc/tools/lxc_snapshot.c @@ -55,7 +55,7 @@ static struct lxc_arguments my_args = { lxc-snapshot snapshots a container\n\ \n\ Options :\n\ - -n, --name=NAME NAME of the container\n\ + -n, --name=NAME NAME of the container\n\ -L, --list list all snapshots\n\ -r, --restore=NAME restore snapshot NAME, e.g. 'snap0'\n\ -N, --newname=NEWNAME NEWNAME for the restored container\n\ diff --git a/src/lxc/tools/lxc_usernsexec.c b/src/lxc/tools/lxc_usernsexec.c index 6745ac308..27d9cf5f6 100644 --- a/src/lxc/tools/lxc_usernsexec.c +++ b/src/lxc/tools/lxc_usernsexec.c @@ -59,7 +59,7 @@ static void usage(const char *name) { printf("usage: %s [-h] [-m ] -- [command [arg ..]]\n", name); printf("\n"); - printf(" -h this message\n"); + printf(" -h this message\n"); printf("\n"); printf(" -m uid maps to use\n"); printf("\n");