If the system gets into a bad state, it may become impossible to get the lxc container locks. We should still be able to stop containers in that case. Add a -L/--nolock option to specify this behavior.
Signed-off-by: Serge Hallyn <serge.hal...@ubuntu.com> --- doc/lxc-stop.sgml.in | 14 ++++++++++++++ src/lxc/arguments.h | 3 +++ src/lxc/lxc_stop.c | 8 ++++++++ 3 files changed, 25 insertions(+) diff --git a/doc/lxc-stop.sgml.in b/doc/lxc-stop.sgml.in index d5f8510..d817a99 100644 --- a/doc/lxc-stop.sgml.in +++ b/doc/lxc-stop.sgml.in @@ -54,6 +54,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA <arg choice="opt">-r</arg> <arg choice="opt">-t <replaceable>timeout</replaceable></arg> <arg choice="opt">-k</arg> + <arg choice="opt">-L</arg> <arg choice="opt">-s</arg> </cmdsynopsis> </refsynopsisdiv> @@ -122,6 +123,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA <varlistentry> <term> + <option>-L,--nolock </option> + </term> + <listitem> + <para> + This option avoids the use of any of the API lxc locking, and should + only be used if <command>lxc-stop</command> is hanging due to a bad + system state. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term> <option>-W,--nowait </option> </term> <listitem> diff --git a/src/lxc/arguments.h b/src/lxc/arguments.h index 021f552..f574fc4 100644 --- a/src/lxc/arguments.h +++ b/src/lxc/arguments.h @@ -73,6 +73,9 @@ struct lxc_arguments { int hardstop; int shutdown; + /* for lxc-stop */ + int nolock; + /* for lxc-destroy */ int force; diff --git a/src/lxc/lxc_stop.c b/src/lxc/lxc_stop.c index 7203d75..fc541a0 100644 --- a/src/lxc/lxc_stop.c +++ b/src/lxc/lxc_stop.c @@ -41,6 +41,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg) case 't': args->timeout = atoi(arg); break; case 'k': args->hardstop = 1; break; case 's': args->shutdown = 1; break; + case 'L': args->nolock = 1; break; } return 0; } @@ -51,6 +52,7 @@ static const struct option my_longopts[] = { {"timeout", required_argument, 0, 't'}, {"kill", no_argument, 0, 'k'}, {"shutdown", no_argument, 0, 's'}, + {"no-lock", no_argument, 0, 'L'}, LXC_COMMON_OPTIONS }; @@ -67,6 +69,7 @@ Options :\n\ -W, --nowait don't wait for shutdown or reboot to complete\n\ -t, --timeout=T wait T seconds before hard-stopping\n\ -k, --kill kill container rather than request clean shutdown\n\ + -L, --nolock Avoid using API locks\n\ -s, --shutdown Only request clean shutdown, don't later force kill\n", .options = my_longopts, .parser = my_parser, @@ -139,6 +142,11 @@ int main(int argc, char *argv[]) my_args.progname, my_args.quiet, my_args.lxcpath[0])) return 1; + /* shortcut - if locking is bogus, we should be able to kill + * containers at least */ + if (my_args.nolock) + return lxc_cmd_stop(my_args.name, my_args.lxcpath[0]); + c = lxc_container_new(my_args.name, my_args.lxcpath[0]); if (!c) { fprintf(stderr, "Error opening container\n"); -- 1.8.5.1 _______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel