diff options
| author | Bogdan Purcareata <bogdan.purcareata@freescale.com> | 2015-03-10 10:28:03 +0000 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@windriver.com> | 2015-03-10 13:14:57 -0400 |
| commit | ea1539e965d871c19bddbe77f4d1bb1a0124afe6 (patch) | |
| tree | a460c7acc8b04a05111f40268a35308e66a5cca1 | |
| parent | 57336a83ac2ab78680f747f5501cea81d077c89e (diff) | |
| download | meta-virtualization-ea1539e965d871c19bddbe77f4d1bb1a0124afe6.tar.gz | |
lxc: fix reboot for Busybox containers
Busybox powered containers rely on a different signal for reboot - SIGTERM,
rather than the default SIGINT.
Apply the upstream support adding the infrastructure for defining a custom
reboot signal for a container, and default this signal to SIGTERM for Busybox
containers. The original patches have been applied on the upstream master LXC
branch, and required a minor backport.
Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
4 files changed, 270 insertions, 0 deletions
diff --git a/recipes-containers/lxc/files/add-lxc.rebootsignal.patch b/recipes-containers/lxc/files/add-lxc.rebootsignal.patch new file mode 100644 index 00000000..e54d188f --- /dev/null +++ b/recipes-containers/lxc/files/add-lxc.rebootsignal.patch | |||
| @@ -0,0 +1,96 @@ | |||
| 1 | From dd267776ee265737520c2c661a51c2d29cf43cb0 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Bogdan Purcareata <bogdan.purcareata@freescale.com> | ||
| 3 | Date: Mon, 16 Feb 2015 09:38:34 +0000 | ||
| 4 | Subject: [PATCH 10/12] add lxc.rebootsignal | ||
| 5 | |||
| 6 | Following the model of f0f1d8c076ae93d8ecf735c2eeae471e27ca6abd, add a reboot | ||
| 7 | signal for special init processes that work on something other than SIGINT. | ||
| 8 | |||
| 9 | Upstream-Status: Accepted | ||
| 10 | [https://github.com/lxc/lxc/commit/dd267776ee265737520c2c661a51c2d29cf43cb0] | ||
| 11 | |||
| 12 | Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com> | ||
| 13 | Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com> | ||
| 14 | --- | ||
| 15 | src/lxc/conf.h | 1 + | ||
| 16 | src/lxc/confile.c | 14 ++++++++++++++ | ||
| 17 | src/lxc/lxccontainer.c | 5 ++++- | ||
| 18 | 3 files changed, 19 insertions(+), 1 deletion(-) | ||
| 19 | |||
| 20 | diff --git a/src/lxc/conf.h b/src/lxc/conf.h | ||
| 21 | index afa5517..334ea70 100644 | ||
| 22 | --- a/src/lxc/conf.h | ||
| 23 | +++ b/src/lxc/conf.h | ||
| 24 | @@ -323,6 +323,7 @@ struct lxc_conf { | ||
| 25 | int maincmd_fd; | ||
| 26 | int autodev; // if 1, mount and fill a /dev at start | ||
| 27 | int haltsignal; // signal used to halt container | ||
| 28 | + int rebootsignal; // signal used to reboot container | ||
| 29 | int stopsignal; // signal used to hard stop container | ||
| 30 | int kmsg; // if 1, create /dev/kmsg symlink | ||
| 31 | char *rcfile; // Copy of the top level rcfile we read | ||
| 32 | diff --git a/src/lxc/confile.c b/src/lxc/confile.c | ||
| 33 | index 8544ac9..42d42e5 100644 | ||
| 34 | --- a/src/lxc/confile.c | ||
| 35 | +++ b/src/lxc/confile.c | ||
| 36 | @@ -98,6 +98,7 @@ static int config_includefile(const char *, const char *, struct lxc_conf *); | ||
| 37 | static int config_network_nic(const char *, const char *, struct lxc_conf *); | ||
| 38 | static int config_autodev(const char *, const char *, struct lxc_conf *); | ||
| 39 | static int config_haltsignal(const char *, const char *, struct lxc_conf *); | ||
| 40 | +static int config_rebootsignal(const char *, const char *, struct lxc_conf *); | ||
| 41 | static int config_stopsignal(const char *, const char *, struct lxc_conf *); | ||
| 42 | static int config_start(const char *, const char *, struct lxc_conf *); | ||
| 43 | static int config_group(const char *, const char *, struct lxc_conf *); | ||
| 44 | @@ -158,6 +159,7 @@ static struct lxc_config_t config[] = { | ||
| 45 | { "lxc.include", config_includefile }, | ||
| 46 | { "lxc.autodev", config_autodev }, | ||
| 47 | { "lxc.haltsignal", config_haltsignal }, | ||
| 48 | + { "lxc.rebootsignal", config_rebootsignal }, | ||
| 49 | { "lxc.stopsignal", config_stopsignal }, | ||
| 50 | { "lxc.start.auto", config_start }, | ||
| 51 | { "lxc.start.delay", config_start }, | ||
| 52 | @@ -1268,6 +1270,18 @@ static int config_haltsignal(const char *key, const char *value, | ||
| 53 | return 0; | ||
| 54 | } | ||
| 55 | |||
| 56 | +static int config_rebootsignal(const char *key, const char *value, | ||
| 57 | + struct lxc_conf *lxc_conf) | ||
| 58 | +{ | ||
| 59 | + int sig_n = sig_parse(value); | ||
| 60 | + | ||
| 61 | + if (sig_n < 0) | ||
| 62 | + return -1; | ||
| 63 | + lxc_conf->rebootsignal = sig_n; | ||
| 64 | + | ||
| 65 | + return 0; | ||
| 66 | +} | ||
| 67 | + | ||
| 68 | static int config_stopsignal(const char *key, const char *value, | ||
| 69 | struct lxc_conf *lxc_conf) | ||
| 70 | { | ||
| 71 | diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c | ||
| 72 | index e02ee93..4422f4a 100644 | ||
| 73 | --- a/src/lxc/lxccontainer.c | ||
| 74 | +++ b/src/lxc/lxccontainer.c | ||
| 75 | @@ -1363,6 +1363,7 @@ free_tpath: | ||
| 76 | static bool lxcapi_reboot(struct lxc_container *c) | ||
| 77 | { | ||
| 78 | pid_t pid; | ||
| 79 | + int rebootsignal = SIGINT; | ||
| 80 | |||
| 81 | if (!c) | ||
| 82 | return false; | ||
| 83 | @@ -1371,7 +1372,9 @@ static bool lxcapi_reboot(struct lxc_container *c) | ||
| 84 | pid = c->init_pid(c); | ||
| 85 | if (pid <= 0) | ||
| 86 | return false; | ||
| 87 | - if (kill(pid, SIGINT) < 0) | ||
| 88 | + if (c->lxc_conf && c->lxc_conf->rebootsignal) | ||
| 89 | + rebootsignal = c->lxc_conf->rebootsignal; | ||
| 90 | + if (kill(pid, rebootsignal) < 0) | ||
| 91 | return false; | ||
| 92 | return true; | ||
| 93 | |||
| 94 | -- | ||
| 95 | 2.1.4 | ||
| 96 | |||
diff --git a/recipes-containers/lxc/files/document-lxc.rebootsignal.patch b/recipes-containers/lxc/files/document-lxc.rebootsignal.patch new file mode 100644 index 00000000..d1cce40f --- /dev/null +++ b/recipes-containers/lxc/files/document-lxc.rebootsignal.patch | |||
| @@ -0,0 +1,140 @@ | |||
| 1 | From baefc2176780b5e4527c1f86206c0ea72d80c8f5 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Bogdan Purcareata <bogdan.purcareata@freescale.com> | ||
| 3 | Date: Tue, 10 Mar 2015 10:06:58 +0000 | ||
| 4 | Subject: [PATCH] document lxc.rebootsignal | ||
| 5 | |||
| 6 | Also fix some minor indentation mishaps since we're here. | ||
| 7 | |||
| 8 | Upstrem-Status: Backport [from LXC 1.1] | ||
| 9 | [https://github.com/lxc/lxc/commit/936762f3fb6cf10e0756719f03aebe052d5c31a8] | ||
| 10 | |||
| 11 | Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com> | ||
| 12 | Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com> | ||
| 13 | --- | ||
| 14 | doc/lxc-stop.sgml.in | 4 +- | ||
| 15 | doc/lxc.container.conf.sgml.in | 86 ++++++++++++++++++++++++++---------------- | ||
| 16 | 2 files changed, 57 insertions(+), 33 deletions(-) | ||
| 17 | |||
| 18 | diff --git a/doc/lxc-stop.sgml.in b/doc/lxc-stop.sgml.in | ||
| 19 | index bc5e6a8..3c69fed 100644 | ||
| 20 | --- a/doc/lxc-stop.sgml.in | ||
| 21 | +++ b/doc/lxc-stop.sgml.in | ||
| 22 | @@ -70,7 +70,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 23 | the container's init process, waiting up to 60 seconds for the container | ||
| 24 | to exit, and then returning. If the container fails to cleanly exit in | ||
| 25 | 60 seconds, it will be sent the <command>lxc.stopsignal</command> | ||
| 26 | - (defaults to SIGKILL) to force it to shut down. | ||
| 27 | + (defaults to SIGKILL) to force it to shut down. A request to reboot will | ||
| 28 | + send the <command>lxc.rebootsignal</command> (defaults to SIGINT) to the | ||
| 29 | + container's init process. | ||
| 30 | </para> | ||
| 31 | <para> | ||
| 32 | The <optional>-W</optional>, <optional>-r</optional>, | ||
| 33 | diff --git a/doc/lxc.container.conf.sgml.in b/doc/lxc.container.conf.sgml.in | ||
| 34 | index e98496d..1962528 100644 | ||
| 35 | --- a/doc/lxc.container.conf.sgml.in | ||
| 36 | +++ b/doc/lxc.container.conf.sgml.in | ||
| 37 | @@ -158,46 +158,68 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 38 | <refsect2> | ||
| 39 | <title>Halt signal</title> | ||
| 40 | <para> | ||
| 41 | - Allows one to specify signal name or number, sent by lxc-stop to the | ||
| 42 | - container's init process to cleanly shutdown the container. Different | ||
| 43 | - init systems could use different signals to perform clean shutdown | ||
| 44 | - sequence. This option allows the signal to be specified in kill(1) | ||
| 45 | - fashion, e.g. SIGPWR, SIGRTMIN+14, SIGRTMAX-10 or plain number. The | ||
| 46 | - default signal is SIGPWR. | ||
| 47 | + Allows one to specify signal name or number, sent by lxc-stop to the | ||
| 48 | + container's init process to cleanly shutdown the container. Different | ||
| 49 | + init systems could use different signals to perform clean shutdown | ||
| 50 | + sequence. This option allows the signal to be specified in kill(1) | ||
| 51 | + fashion, e.g. SIGPWR, SIGRTMIN+14, SIGRTMAX-10 or plain number. The | ||
| 52 | + default signal is SIGPWR. | ||
| 53 | </para> | ||
| 54 | <variablelist> | ||
| 55 | - <varlistentry> | ||
| 56 | - <term> | ||
| 57 | - <option>lxc.haltsignal</option> | ||
| 58 | - </term> | ||
| 59 | - <listitem> | ||
| 60 | - <para> | ||
| 61 | - specify the signal used to halt the container | ||
| 62 | - </para> | ||
| 63 | - </listitem> | ||
| 64 | - </varlistentry> | ||
| 65 | + <varlistentry> | ||
| 66 | + <term> | ||
| 67 | + <option>lxc.haltsignal</option> | ||
| 68 | + </term> | ||
| 69 | + <listitem> | ||
| 70 | + <para> | ||
| 71 | + specify the signal used to halt the container | ||
| 72 | + </para> | ||
| 73 | + </listitem> | ||
| 74 | + </varlistentry> | ||
| 75 | + </variablelist> | ||
| 76 | + </refsect2> | ||
| 77 | + | ||
| 78 | + <refsect2> | ||
| 79 | + <title>Reboot signal</title> | ||
| 80 | + <para> | ||
| 81 | + Allows one to specify signal name or number, sent by lxc-stop to | ||
| 82 | + reboot the container. This option allows signal to be specified in | ||
| 83 | + kill(1) fashion, e.g. SIGTERM, SIGRTMIN+14, SIGRTMAX-10 or plain number. | ||
| 84 | + The default signal is SIGINT. | ||
| 85 | + </para> | ||
| 86 | + <variablelist> | ||
| 87 | + <varlistentry> | ||
| 88 | + <term> | ||
| 89 | + <option>lxc.rebootsignal</option> | ||
| 90 | + </term> | ||
| 91 | + <listitem> | ||
| 92 | + <para> | ||
| 93 | + specify the signal used to reboot the container | ||
| 94 | + </para> | ||
| 95 | + </listitem> | ||
| 96 | + </varlistentry> | ||
| 97 | </variablelist> | ||
| 98 | </refsect2> | ||
| 99 | |||
| 100 | <refsect2> | ||
| 101 | <title>Stop signal</title> | ||
| 102 | <para> | ||
| 103 | - Allows one to specify signal name or number, sent by lxc-stop to forcibly | ||
| 104 | - shutdown the container. This option allows signal to be specified in | ||
| 105 | - kill(1) fashion, e.g. SIGKILL, SIGRTMIN+14, SIGRTMAX-10 or plain number. | ||
| 106 | - The default signal is SIGKILL. | ||
| 107 | - </para> | ||
| 108 | - <variablelist> | ||
| 109 | - <varlistentry> | ||
| 110 | - <term> | ||
| 111 | - <option>lxc.stopsignal</option> | ||
| 112 | - </term> | ||
| 113 | - <listitem> | ||
| 114 | - <para> | ||
| 115 | - specify the signal used to stop the container | ||
| 116 | - </para> | ||
| 117 | - </listitem> | ||
| 118 | - </varlistentry> | ||
| 119 | + Allows one to specify signal name or number, sent by lxc-stop to forcibly | ||
| 120 | + shutdown the container. This option allows signal to be specified in | ||
| 121 | + kill(1) fashion, e.g. SIGKILL, SIGRTMIN+14, SIGRTMAX-10 or plain number. | ||
| 122 | + The default signal is SIGKILL. | ||
| 123 | + </para> | ||
| 124 | + <variablelist> | ||
| 125 | + <varlistentry> | ||
| 126 | + <term> | ||
| 127 | + <option>lxc.stopsignal</option> | ||
| 128 | + </term> | ||
| 129 | + <listitem> | ||
| 130 | + <para> | ||
| 131 | + specify the signal used to stop the container | ||
| 132 | + </para> | ||
| 133 | + </listitem> | ||
| 134 | + </varlistentry> | ||
| 135 | </variablelist> | ||
| 136 | </refsect2> | ||
| 137 | |||
| 138 | -- | ||
| 139 | 2.1.4 | ||
| 140 | |||
diff --git a/recipes-containers/lxc/files/lxc-busybox-use-lxc.rebootsignal-SIGTERM.patch b/recipes-containers/lxc/files/lxc-busybox-use-lxc.rebootsignal-SIGTERM.patch new file mode 100644 index 00000000..2f4513ee --- /dev/null +++ b/recipes-containers/lxc/files/lxc-busybox-use-lxc.rebootsignal-SIGTERM.patch | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | From 22fb28a946397ec19b247efe170c15b263bf89af Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Bogdan Purcareata <bogdan.purcareata@freescale.com> | ||
| 3 | Date: Mon, 16 Feb 2015 09:38:36 +0000 | ||
| 4 | Subject: [PATCH 12/12] lxc-busybox: use lxc.rebootsignal = SIGTERM | ||
| 5 | |||
| 6 | Otherwise lxc-stop -r has no effect on the container. | ||
| 7 | |||
| 8 | Upstream-Status: Accepted | ||
| 9 | [https://github.com/lxc/lxc/commit/22fb28a946397ec19b247efe170c15b263bf89af] | ||
| 10 | |||
| 11 | Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com> | ||
| 12 | Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com> | ||
| 13 | --- | ||
| 14 | templates/lxc-busybox.in | 1 + | ||
| 15 | 1 file changed, 1 insertion(+) | ||
| 16 | |||
| 17 | diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in | ||
| 18 | index 72531d6..7e05bd6 100644 | ||
| 19 | --- a/templates/lxc-busybox.in | ||
| 20 | +++ b/templates/lxc-busybox.in | ||
| 21 | @@ -270,6 +270,7 @@ copy_configuration() | ||
| 22 | grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config | ||
| 23 | cat <<EOF >> $path/config | ||
| 24 | lxc.haltsignal = SIGUSR1 | ||
| 25 | +lxc.rebootsignal = SIGTERM | ||
| 26 | lxc.utsname = $name | ||
| 27 | lxc.tty = 1 | ||
| 28 | lxc.pts = 1 | ||
| 29 | -- | ||
| 30 | 2.1.4 | ||
| 31 | |||
diff --git a/recipes-containers/lxc/lxc_1.0.7.bb b/recipes-containers/lxc/lxc_1.0.7.bb index ecad31c9..c618c848 100644 --- a/recipes-containers/lxc/lxc_1.0.7.bb +++ b/recipes-containers/lxc/lxc_1.0.7.bb | |||
| @@ -26,6 +26,9 @@ SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \ | |||
| 26 | file://runtest.patch \ | 26 | file://runtest.patch \ |
| 27 | file://run-ptest \ | 27 | file://run-ptest \ |
| 28 | file://automake-ensure-VPATH-builds-correctly.patch \ | 28 | file://automake-ensure-VPATH-builds-correctly.patch \ |
| 29 | file://add-lxc.rebootsignal.patch \ | ||
| 30 | file://document-lxc.rebootsignal.patch \ | ||
| 31 | file://lxc-busybox-use-lxc.rebootsignal-SIGTERM.patch \ | ||
| 29 | " | 32 | " |
| 30 | 33 | ||
| 31 | SRC_URI[md5sum] = "b48f468a9bef0e4e140dd723f0a65ad0" | 34 | SRC_URI[md5sum] = "b48f468a9bef0e4e140dd723f0a65ad0" |
