[lxc-devel] [PATCH 1/2] rename lxc-stop shutdown argument to nokill

Dwight Engen dwight.engen at oracle.com
Fri Jan 3 19:36:43 UTC 2014


This makes the arguments between lxc-stop and lxc-autostart more
consistent, so that --shutdown doesn't have two different meanings.

Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
 doc/lxc-stop.sgml.in | 26 +++++++++++++++-----------
 src/lxc/arguments.h  | 11 +++++++----
 src/lxc/lxc_stop.c   |  9 +++++----
 3 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/doc/lxc-stop.sgml.in b/doc/lxc-stop.sgml.in
index 09ea5d6..bdb0ef5 100644
--- a/doc/lxc-stop.sgml.in
+++ b/doc/lxc-stop.sgml.in
@@ -54,7 +54,8 @@ 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">-s</arg>
+      <arg choice="opt">--nokill</arg>
+      <arg choice="opt">--nolock</arg>
     </cmdsynopsis>
   </refsynopsisdiv>
 
@@ -68,11 +69,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
       the container), wait 60 seconds for the container to exit, and
       returns.  If the container fails to cleanly exit, then after 60
       seconds the container will be sent the
-      <command>lxc.stopsignal</command> to force it to shut down.
+      <command>lxc.stopsignal</command> to force it to shut down. If
+      <command>lxc.stopsignal</command> is not specified, the signal sent is
+      SIGKILL.
     </para>
 	<para>
-	The <optional>-W</optional>, <optional>-r</optional>, <optional>-s</optional>
-	and <optional>-k</optional> options specify the action to perform.
+	The <optional>-W</optional>, <optional>-r</optional>,
+	<optional>-k</optional> and <optional>--nokill</optional>
+	options specify the action to perform.
 	<optional>-W</optional> indicates that after performing the specified
 	action, <command>lxc-stop</command> should immediately exit, while
 	<optional>-t TIMEOUT</optional> specifies the maximum amount of time
@@ -97,25 +101,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
     <varlistentry>
 	<term>
-	  <option>-s,--shutdown </option>
+	  <option>-k,--kill </option>
 	</term>
 	<listitem>
 	  <para>
-	    Only request a clean shutdown, do not kill the container tasks if the
-		clean shutdown fails.
+        Rather than requesting a clean shutdown of the container, explicitly
+        kill all tasks in the container.  This is the legacy
+        <command>lxc-stop</command> behavior.
 	  </para>
 	</listitem>
 	</varlistentry>
 
     <varlistentry>
 	<term>
-	  <option>-k,--kill </option>
+	  <option>--nokill</option>
 	</term>
 	<listitem>
 	  <para>
-        Rather than requesting a clean shutdown of the container, explicitly
-        kill all tasks in the container.  This is the legacy
-        <command>lxc-stop</command> behavior.
+	    Only request a clean shutdown, do not kill the container tasks if the
+		clean shutdown fails.
 	  </para>
 	</listitem>
 	</varlistentry>
diff --git a/src/lxc/arguments.h b/src/lxc/arguments.h
index 954ddcc..2fa24c0 100644
--- a/src/lxc/arguments.h
+++ b/src/lxc/arguments.h
@@ -65,16 +65,19 @@ struct lxc_arguments {
 	int ttynum;
 	char escape;
 
-	/* for lxc-wait and lxc-shutdown */
+	/* for lxc-wait */
 	char *states;
 	long timeout;
-	int nowait;
-	int reboot;
-	int hardstop;
+
+	/* for lxc-autostart */
 	int shutdown;
 
 	/* for lxc-stop */
+	int hardstop;
+	int nokill;
 	int nolock;
+	int nowait;
+	int reboot;
 
 	/* for lxc-destroy */
 	int force;
diff --git a/src/lxc/lxc_stop.c b/src/lxc/lxc_stop.c
index d0cf798..dc4133f 100644
--- a/src/lxc/lxc_stop.c
+++ b/src/lxc/lxc_stop.c
@@ -34,6 +34,7 @@
 #include "utils.h"
 
 #define OPT_NO_LOCK OPT_USAGE+1
+#define OPT_NO_KILL OPT_USAGE+2
 
 static int my_parser(struct lxc_arguments* args, int c, char* arg)
 {
@@ -42,8 +43,8 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
 	case 'W': args->nowait = 1; break;
 	case 't': args->timeout = atoi(arg); break;
 	case 'k': args->hardstop = 1; break;
-	case 's': args->shutdown = 1; break;
 	case OPT_NO_LOCK: args->nolock = 1; break;
+	case OPT_NO_KILL: args->nokill = 1; break;
 	}
 	return 0;
 }
@@ -53,7 +54,7 @@ static const struct option my_longopts[] = {
 	{"nowait", no_argument, 0, 'W'},
 	{"timeout", required_argument, 0, 't'},
 	{"kill", no_argument, 0, 'k'},
-	{"shutdown", no_argument, 0, 's'},
+	{"no-kill", no_argument, 0, OPT_NO_KILL},
 	{"no-lock", no_argument, 0, OPT_NO_LOCK},
 	LXC_COMMON_OPTIONS
 };
@@ -72,7 +73,7 @@ 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\
-  -s, --shutdown    Only request clean shutdown, don't later force kill\n",
+      --nokill      Only request clean shutdown, don't force kill after timeout\n",
 	.options  = my_longopts,
 	.parser   = my_parser,
 	.checker  = NULL,
@@ -175,7 +176,7 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 
-	if (my_args.shutdown)
+	if (my_args.nokill)
 		my_args.timeout = 0;
 
 	s = c->shutdown(c, my_args.timeout);
-- 
1.8.3.1



More information about the lxc-devel mailing list