]> git.proxmox.com Git - mirror_lxc.git/commitdiff
add lxc.rebootsignal
authorBogdan Purcareata <bogdan.purcareata@freescale.com>
Mon, 16 Feb 2015 09:38:34 +0000 (09:38 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Wed, 18 Feb 2015 17:42:36 +0000 (09:42 -0800)
Following the model of f0f1d8c076ae93d8ecf735c2eeae471e27ca6abd, add a reboot
signal for special init processes that work on something other than SIGINT.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/conf.h
src/lxc/confile.c
src/lxc/lxccontainer.c

index afa55179d243243e0775c4ce639580ab10c3fd86..334ea704256f1df1e8e152af37fc277d19d0da59 100644 (file)
@@ -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
index 8544ac9b7c678ed8d5a6a6a86683db8be495b3cd..42d42e5ea58c9c23d4747c020f8f5a9f39172612 100644 (file)
@@ -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)
 {
index e02ee93e9536f14156bdaeca1e9390545b6411e5..4422f4ad0b7170dc6c603a299bc500a43da396e1 100644 (file)
@@ -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;