From 55c84efcba718fb2b5390c1d2214ea0307e6ccdf Mon Sep 17 00:00:00 2001 From: 0x0916 Date: Wed, 28 Jun 2017 19:26:02 +0800 Subject: [PATCH] confile: namespace lxc.signal keys * rename lxc.haltsignal to lxc.signal.halt * rename lxc.rebootsignal to lxc.signal.reboot * rename lxc.stopsignal to lxc.signal.stop the legacy keys will be kept around until LXC 3.0 and then will be removed. Signed-off-by: 0x0916 --- config/templates/archlinux.common.conf.in | 4 +-- config/templates/voidlinux.common.conf.in | 2 +- config/templates/voidlinux.userns.conf.in | 2 +- doc/ja/lxc-stop.sgml.in | 12 +++---- doc/ja/lxc.container.conf.sgml.in | 6 ++-- doc/ko/lxc-stop.sgml.in | 10 +++--- doc/ko/lxc.container.conf.sgml.in | 6 ++-- doc/lxc-stop.sgml.in | 6 ++-- doc/lxc.container.conf.sgml.in | 6 ++-- src/lxc/confile.c | 38 ++++++++++++++--------- src/tests/parse_config_file.c | 33 ++++++++++++++++++-- templates/lxc-busybox.in | 2 +- 12 files changed, 81 insertions(+), 46 deletions(-) diff --git a/config/templates/archlinux.common.conf.in b/config/templates/archlinux.common.conf.in index f86949138..043b27cc5 100644 --- a/config/templates/archlinux.common.conf.in +++ b/config/templates/archlinux.common.conf.in @@ -5,8 +5,8 @@ lxc.include = @LXCTEMPLATECONFIG@/common.conf lxc.tty = 6 # Set the halt/stop signals -lxc.haltsignal=SIGRTMIN+4 -lxc.stopsignal=SIGRTMIN+14 +lxc.signal.halt=SIGRTMIN+4 +lxc.signal.stop=SIGRTMIN+14 # Uncomment to disable creating tty devices subdirectory in /dev # lxc.devttydir = diff --git a/config/templates/voidlinux.common.conf.in b/config/templates/voidlinux.common.conf.in index d5d2ee81c..41ab1a2fe 100644 --- a/config/templates/voidlinux.common.conf.in +++ b/config/templates/voidlinux.common.conf.in @@ -8,7 +8,7 @@ lxc.tty = 6 lxc.environment=VIRTUALIZATION=lxc # Set the halt/stop signals -lxc.haltsignal=SIGCONT +lxc.signal.halt=SIGCONT # Uncomment to disable creating tty devices subdirectory in /dev diff --git a/config/templates/voidlinux.userns.conf.in b/config/templates/voidlinux.userns.conf.in index 5e346b7c5..f319bc546 100644 --- a/config/templates/voidlinux.userns.conf.in +++ b/config/templates/voidlinux.userns.conf.in @@ -5,4 +5,4 @@ lxc.include = @LXCTEMPLATECONFIG@/userns.conf lxc.environment=VIRTUALIZATION=lxc # Set the halt/stop signals -lxc.haltsignal=SIGCONT +lxc.signal.halt=SIGCONT diff --git a/doc/ja/lxc-stop.sgml.in b/doc/ja/lxc-stop.sgml.in index 79f7a9a3e..1648851bd 100644 --- a/doc/ja/lxc-stop.sgml.in +++ b/doc/ja/lxc-stop.sgml.in @@ -73,18 +73,18 @@ by KATOH Yasufumi lxc-stop reboots, cleanly shuts down, or kills all the processes inside the container. By default, it will request a clean shutdown of the container by sending - lxc.haltsignal (defaults to SIGPWR) to + lxc.signal.halt (defaults to SIGPWR) to the container's init process, waiting up to 60 seconds for the container to exit, and then returning. If the container fails to cleanly exit in - 60 seconds, it will be sent the lxc.stopsignal + 60 seconds, it will be sent the lxc.signal.stop (defaults to SIGKILL) to force it to shut down. A request to reboot will - send the lxc.rebootsignal (defaults to SIGINT) to the + send the lxc.signal.reboot (defaults to SIGINT) to the container's init process. --> lxc-stop は、リブート、クリーンシャットダウン、コンテナ内の全てのプロセスの kill のどれかを行います。 - デフォルトでは、コンテナのクリーンなシャットダウンを lxc.haltsignal (デフォルトでは SIGPWR) をコンテナの init プロセスに送ることでリクエストし、コンテナの終了を 60 秒待ち、return します。 - コンテナが 60 秒の間にクリーンに終了するのに失敗した場合、lxc.stopsignal (デフォルトは SIGKILL です) を送り、強制的にシャットダウンします。 - リブートのリクエストは lxc.rebootsignal に設定されたシグナルをコンテナの init プロセスに送ります (デフォルトは SIGINT です)。 + デフォルトでは、コンテナのクリーンなシャットダウンを lxc.signal.halt (デフォルトでは SIGPWR) をコンテナの init プロセスに送ることでリクエストし、コンテナの終了を 60 秒待ち、return します。 + コンテナが 60 秒の間にクリーンに終了するのに失敗した場合、lxc.signal.stop (デフォルトは SIGKILL です) を送り、強制的にシャットダウンします。 + リブートのリクエストは lxc.signal.reboot に設定されたシグナルをコンテナの init プロセスに送ります (デフォルトは SIGINT です)。 diff --git a/doc/ja/lxc.container.conf.sgml.in b/doc/ja/lxc.container.conf.sgml.in index 2835b0507..e941fcec7 100644 --- a/doc/ja/lxc.container.conf.sgml.in +++ b/doc/ja/lxc.container.conf.sgml.in @@ -260,7 +260,7 @@ by KATOH Yasufumi - + @@ -289,7 +289,7 @@ by KATOH Yasufumi - + @@ -318,7 +318,7 @@ by KATOH Yasufumi - + diff --git a/doc/ko/lxc-stop.sgml.in b/doc/ko/lxc-stop.sgml.in index e50f029d8..af14d8436 100644 --- a/doc/ko/lxc-stop.sgml.in +++ b/doc/ko/lxc-stop.sgml.in @@ -73,16 +73,16 @@ by Sungbae Yoo lxc-stop reboots, cleanly shuts down, or kills all the processes inside the container. By default, it will request a clean shutdown of the container by sending - lxc.haltsignal (defaults to SIGPWR) to + lxc.signal.halt (defaults to SIGPWR) to the container's init process, waiting up to 60 seconds for the container to exit, and then returning. If the container fails to cleanly exit in - 60 seconds, it will be sent the lxc.stopsignal + 60 seconds, it will be sent the lxc.signal.stop (defaults to SIGKILL) to force it to shut down. A request to reboot will - send the lxc.rebootsignal (defaults to SIGINT) to the + send the lxc.signal.reboot (defaults to SIGINT) to the container's init process. --> - lxc-stop 는 재뷰탕, 종료, 또는 컨테이너 내의 모든 프로세스를 강제종료 시킨다. 기본 동작은 컨테이너에게 lxc.haltsignal 시그널(기본값은 SIGPWR)을 컨테이너 init 프로세스에게 날려, 컨테이너가 종료되게 요청하는 것이다. 60초 동안 컨테이너가 종료되는 것을 기다리고 리턴된다. -만약 컨테이너가 60초안에 종료되지 않는다면 lxc.stopsignal 시그널(기본값은 SIGKILL)을 날려 강제로 종료시킨다. 재부팅 요청시에는 lxc.rebootsignal 시그널(기본값은 SIGINT)를 컨테이너 init 프로세스에게 날린다. + lxc-stop 는 재뷰탕, 종료, 또는 컨테이너 내의 모든 프로세스를 강제종료 시킨다. 기본 동작은 컨테이너에게 lxc.signal.halt 시그널(기본값은 SIGPWR)을 컨테이너 init 프로세스에게 날려, 컨테이너가 종료되게 요청하는 것이다. 60초 동안 컨테이너가 종료되는 것을 기다리고 리턴된다. +만약 컨테이너가 60초안에 종료되지 않는다면 lxc.signal.stop 시그널(기본값은 SIGKILL)을 날려 강제로 종료시킨다. 재부팅 요청시에는 lxc.signal.reboot 시그널(기본값은 SIGINT)를 컨테이너 init 프로세스에게 날린다. diff --git a/doc/ko/lxc.container.conf.sgml.in b/doc/ko/lxc.container.conf.sgml.in index 1bbf8f440..738748b52 100644 --- a/doc/ko/lxc.container.conf.sgml.in +++ b/doc/ko/lxc.container.conf.sgml.in @@ -219,7 +219,7 @@ by Sungbae Yoo - + @@ -248,7 +248,7 @@ by Sungbae Yoo - + @@ -277,7 +277,7 @@ by Sungbae Yoo - + diff --git a/doc/lxc-stop.sgml.in b/doc/lxc-stop.sgml.in index 3c69feda5..09db5f621 100644 --- a/doc/lxc-stop.sgml.in +++ b/doc/lxc-stop.sgml.in @@ -66,12 +66,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA lxc-stop reboots, cleanly shuts down, or kills all the processes inside the container. By default, it will request a clean shutdown of the container by sending - lxc.haltsignal (defaults to SIGPWR) to + lxc.signal.halt (defaults to SIGPWR) to the container's init process, waiting up to 60 seconds for the container to exit, and then returning. If the container fails to cleanly exit in - 60 seconds, it will be sent the lxc.stopsignal + 60 seconds, it will be sent the lxc.signal.stop (defaults to SIGKILL) to force it to shut down. A request to reboot will - send the lxc.rebootsignal (defaults to SIGINT) to the + send the lxc.signal.reboot (defaults to SIGINT) to the container's init process. diff --git a/doc/lxc.container.conf.sgml.in b/doc/lxc.container.conf.sgml.in index 0ef45c494..3b639dd7f 100644 --- a/doc/lxc.container.conf.sgml.in +++ b/doc/lxc.container.conf.sgml.in @@ -196,7 +196,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - + @@ -218,7 +218,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - + @@ -240,7 +240,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - + diff --git a/src/lxc/confile.c b/src/lxc/confile.c index 1af6f5f66..d9fa41269 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -118,9 +118,9 @@ lxc_config_define(console); lxc_config_define(seccomp); lxc_config_define(includefiles); lxc_config_define(autodev); -lxc_config_define(haltsignal); -lxc_config_define(rebootsignal); -lxc_config_define(stopsignal); +lxc_config_define(signal_halt); +lxc_config_define(signal_reboot); +lxc_config_define(signal_stop); lxc_config_define(start); lxc_config_define(monitor); lxc_config_define(group); @@ -215,9 +215,17 @@ static struct lxc_config_t config[] = { { "lxc.seccomp", set_config_seccomp, get_config_seccomp, clr_config_seccomp, }, { "lxc.include", set_config_includefiles, get_config_includefiles, clr_config_includefiles, }, { "lxc.autodev", set_config_autodev, get_config_autodev, clr_config_autodev, }, - { "lxc.haltsignal", set_config_haltsignal, get_config_haltsignal, clr_config_haltsignal, }, - { "lxc.rebootsignal", set_config_rebootsignal, get_config_rebootsignal, clr_config_rebootsignal, }, - { "lxc.stopsignal", set_config_stopsignal, get_config_stopsignal, clr_config_stopsignal, }, + + /* REMOVE IN LXC 3.0 + legacy singal keys + */ + { "lxc.haltsignal", set_config_signal_halt, get_config_signal_halt, clr_config_signal_halt, }, + { "lxc.rebootsignal", set_config_signal_reboot, get_config_signal_reboot, clr_config_signal_reboot, }, + { "lxc.stopsignal", set_config_signal_stop, get_config_signal_stop, clr_config_signal_stop, }, + + { "lxc.signal.halt", set_config_signal_halt, get_config_signal_halt, clr_config_signal_halt, }, + { "lxc.signal.reboot", set_config_signal_reboot, get_config_signal_reboot, clr_config_signal_reboot, }, + { "lxc.signal.stop", set_config_signal_stop, get_config_signal_stop, clr_config_signal_stop, }, { "lxc.start.auto", set_config_start, get_config_start, clr_config_start, }, { "lxc.start.delay", set_config_start, get_config_start, clr_config_start, }, { "lxc.start.order", set_config_start, get_config_start, clr_config_start, }, @@ -1446,7 +1454,7 @@ static int sig_parse(const char *signame) return -1; } -static int set_config_haltsignal(const char *key, const char *value, +static int set_config_signal_halt(const char *key, const char *value, struct lxc_conf *lxc_conf, void *data) { int sig_n; @@ -1467,7 +1475,7 @@ static int set_config_haltsignal(const char *key, const char *value, return 0; } -static int set_config_rebootsignal(const char *key, const char *value, +static int set_config_signal_reboot(const char *key, const char *value, struct lxc_conf *lxc_conf, void *data) { int sig_n; @@ -1487,7 +1495,7 @@ static int set_config_rebootsignal(const char *key, const char *value, return 0; } -static int set_config_stopsignal(const char *key, const char *value, +static int set_config_signal_stop(const char *key, const char *value, struct lxc_conf *lxc_conf, void *data) { int sig_n; @@ -3159,19 +3167,19 @@ static int get_config_autodev(const char *key, char *retv, int inlen, return lxc_get_conf_int(c, retv, inlen, c->autodev); } -static int get_config_haltsignal(const char *key, char *retv, int inlen, +static int get_config_signal_halt(const char *key, char *retv, int inlen, struct lxc_conf *c, void *data) { return lxc_get_conf_int(c, retv, inlen, c->haltsignal); } -static int get_config_rebootsignal(const char *key, char *retv, int inlen, +static int get_config_signal_reboot(const char *key, char *retv, int inlen, struct lxc_conf *c, void *data) { return lxc_get_conf_int(c, retv, inlen, c->rebootsignal); } -static int get_config_stopsignal(const char *key, char *retv, int inlen, +static int get_config_signal_stop(const char *key, char *retv, int inlen, struct lxc_conf *c, void *data) { return lxc_get_conf_int(c, retv, inlen, c->stopsignal); @@ -3523,21 +3531,21 @@ static inline int clr_config_autodev(const char *key, struct lxc_conf *c, return 0; } -static inline int clr_config_haltsignal(const char *key, struct lxc_conf *c, +static inline int clr_config_signal_halt(const char *key, struct lxc_conf *c, void *data) { c->haltsignal = 0; return 0; } -static inline int clr_config_rebootsignal(const char *key, struct lxc_conf *c, +static inline int clr_config_signal_reboot(const char *key, struct lxc_conf *c, void *data) { c->rebootsignal = 0; return 0; } -static inline int clr_config_stopsignal(const char *key, struct lxc_conf *c, +static inline int clr_config_signal_stop(const char *key, struct lxc_conf *c, void *data) { c->stopsignal = 0; diff --git a/src/tests/parse_config_file.c b/src/tests/parse_config_file.c index b2988d646..bab9c2ff2 100644 --- a/src/tests/parse_config_file.c +++ b/src/tests/parse_config_file.c @@ -636,27 +636,54 @@ int main(int argc, char *argv[]) goto non_test_error; } - /* lxc.haltsignal */ + /* REMOVE IN LXC 3.0 + legacy lxc.haltsignal key + */ if (set_get_compare_clear_save_load(c, "lxc.haltsignal", "1", tmpf, true) < 0) { lxc_error("%s\n", "lxc.haltsignal"); goto non_test_error; } - /* lxc.rebootsignal */ + /* lxc.signal.halt */ + if (set_get_compare_clear_save_load(c, "lxc.signal.halt", "1", tmpf, + true) < 0) { + lxc_error("%s\n", "lxc.signal.halt"); + goto non_test_error; + } + + /* REMOVE IN LXC 3.0 + legacy lxc.rebootsignal key + */ if (set_get_compare_clear_save_load(c, "lxc.rebootsignal", "1", tmpf, true) < 0) { lxc_error("%s\n", "lxc.rebootsignal"); goto non_test_error; } - /* lxc.stopsignal */ + /* lxc.signal.reboot */ + if (set_get_compare_clear_save_load(c, "lxc.signal.reboot", "1", tmpf, + true) < 0) { + lxc_error("%s\n", "lxc.signal.reboot"); + goto non_test_error; + } + + /* REMOVE IN LXC 3.0 + legacy lxc.stopsignal key + */ if (set_get_compare_clear_save_load(c, "lxc.stopsignal", "1", tmpf, true) < 0) { lxc_error("%s\n", "lxc.stopsignal"); goto non_test_error; } + /* lxc.signal.stop */ + if (set_get_compare_clear_save_load(c, "lxc.signal.stop", "1", tmpf, + true) < 0) { + lxc_error("%s\n", "lxc.signal.stop"); + goto non_test_error; + } + /* lxc.start.auto */ if (set_get_compare_clear_save_load(c, "lxc.start.auto", "1", tmpf, true) < 0) { diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in index 0d8db3358..7e11ac3e5 100644 --- a/templates/lxc-busybox.in +++ b/templates/lxc-busybox.in @@ -341,7 +341,7 @@ copy_configuration() grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config cat <> $path/config -lxc.haltsignal = SIGUSR1 +lxc.signal.halt = SIGUSR1 lxc.rebootsignal = SIGTERM lxc.utsname = $name lxc.tty = 1 -- 2.39.5