1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
From dd267776ee265737520c2c661a51c2d29cf43cb0 Mon Sep 17 00:00:00 2001
From: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Date: Mon, 16 Feb 2015 09:38:34 +0000
Subject: [PATCH 10/12] add lxc.rebootsignal
Following the model of f0f1d8c076ae93d8ecf735c2eeae471e27ca6abd, add a reboot
signal for special init processes that work on something other than SIGINT.
Upstream-Status: Accepted
[https://github.com/lxc/lxc/commit/dd267776ee265737520c2c661a51c2d29cf43cb0]
Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
---
src/lxc/conf.h | 1 +
src/lxc/confile.c | 14 ++++++++++++++
src/lxc/lxccontainer.c | 5 ++++-
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/lxc/conf.h b/src/lxc/conf.h
index afa5517..334ea70 100644
--- a/src/lxc/conf.h
+++ b/src/lxc/conf.h
@@ -323,6 +323,7 @@ struct lxc_conf {
int maincmd_fd;
int autodev; // if 1, mount and fill a /dev at start
int haltsignal; // signal used to halt container
+ int rebootsignal; // signal used to reboot container
int stopsignal; // signal used to hard stop container
int kmsg; // if 1, create /dev/kmsg symlink
char *rcfile; // Copy of the top level rcfile we read
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 8544ac9..42d42e5 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -98,6 +98,7 @@ static int config_includefile(const char *, const char *, struct lxc_conf *);
static int config_network_nic(const char *, const char *, struct lxc_conf *);
static int config_autodev(const char *, const char *, struct lxc_conf *);
static int config_haltsignal(const char *, const char *, struct lxc_conf *);
+static int config_rebootsignal(const char *, const char *, struct lxc_conf *);
static int config_stopsignal(const char *, const char *, struct lxc_conf *);
static int config_start(const char *, const char *, struct lxc_conf *);
static int config_group(const char *, const char *, struct lxc_conf *);
@@ -158,6 +159,7 @@ static struct lxc_config_t config[] = {
{ "lxc.include", config_includefile },
{ "lxc.autodev", config_autodev },
{ "lxc.haltsignal", config_haltsignal },
+ { "lxc.rebootsignal", config_rebootsignal },
{ "lxc.stopsignal", config_stopsignal },
{ "lxc.start.auto", config_start },
{ "lxc.start.delay", config_start },
@@ -1268,6 +1270,18 @@ static int config_haltsignal(const char *key, const char *value,
return 0;
}
+static int config_rebootsignal(const char *key, const char *value,
+ struct lxc_conf *lxc_conf)
+{
+ int sig_n = sig_parse(value);
+
+ if (sig_n < 0)
+ return -1;
+ lxc_conf->rebootsignal = sig_n;
+
+ return 0;
+}
+
static int config_stopsignal(const char *key, const char *value,
struct lxc_conf *lxc_conf)
{
diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index e02ee93..4422f4a 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -1363,6 +1363,7 @@ free_tpath:
static bool lxcapi_reboot(struct lxc_container *c)
{
pid_t pid;
+ int rebootsignal = SIGINT;
if (!c)
return false;
@@ -1371,7 +1372,9 @@ static bool lxcapi_reboot(struct lxc_container *c)
pid = c->init_pid(c);
if (pid <= 0)
return false;
- if (kill(pid, SIGINT) < 0)
+ if (c->lxc_conf && c->lxc_conf->rebootsignal)
+ rebootsignal = c->lxc_conf->rebootsignal;
+ if (kill(pid, rebootsignal) < 0)
return false;
return true;
--
2.1.4
|