[lxc-devel] [RFC 3/5] added stop-hook entries

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Sep 23 14:12:08 UTC 2015


---
 src/lxc/conf.c    | 4 +++-
 src/lxc/conf.h    | 2 +-
 src/lxc/confile.c | 3 +++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 0913b22..f81efcd 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -163,7 +163,7 @@ return -1;
 #endif
 
 char *lxchook_names[NUM_LXC_HOOKS] = {
-	"pre-start", "pre-mount", "mount", "autodev", "start", "post-stop", "clone", "destroy" };
+	"pre-start", "pre-mount", "mount", "autodev", "start", "stop", "post-stop", "clone", "destroy" };
 
 typedef int (*instantiate_cb)(struct lxc_handler *, struct lxc_netdev *);
 
@@ -3878,6 +3878,8 @@ int run_lxc_hooks(const char *name, char *hook, struct lxc_conf *conf,
 		which = LXCHOOK_AUTODEV;
 	else if (strcmp(hook, "start") == 0)
 		which = LXCHOOK_START;
+	else if (strcmp(hook, "stop") == 0)
+		which = LXCHOOK_STOP;
 	else if (strcmp(hook, "post-stop") == 0)
 		which = LXCHOOK_POSTSTOP;
 	else if (strcmp(hook, "clone") == 0)
diff --git a/src/lxc/conf.h b/src/lxc/conf.h
index 5aebd91..1374d4a 100644
--- a/src/lxc/conf.h
+++ b/src/lxc/conf.h
@@ -279,7 +279,7 @@ enum {
  */
 enum lxchooks {
 	LXCHOOK_PRESTART, LXCHOOK_PREMOUNT, LXCHOOK_MOUNT, LXCHOOK_AUTODEV,
-	LXCHOOK_START, LXCHOOK_POSTSTOP, LXCHOOK_CLONE, LXCHOOK_DESTROY,
+	LXCHOOK_START, LXCHOOK_STOP, LXCHOOK_POSTSTOP, LXCHOOK_CLONE, LXCHOOK_DESTROY,
 	NUM_LXC_HOOKS};
 extern char *lxchook_names[NUM_LXC_HOOKS];
 
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 670d957..f7d6814 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -137,6 +137,7 @@ static struct lxc_config_t config[] = {
 	{ "lxc.hook.mount",           config_hook                 },
 	{ "lxc.hook.autodev",         config_hook                 },
 	{ "lxc.hook.start",           config_hook                 },
+	{ "lxc.hook.stop",            config_hook                 },
 	{ "lxc.hook.post-stop",       config_hook                 },
 	{ "lxc.hook.clone",           config_hook                 },
 	{ "lxc.hook.destroy",         config_hook                 },
@@ -1085,6 +1086,8 @@ static int config_hook(const char *key, const char *value,
 		return add_hook(lxc_conf, LXCHOOK_MOUNT, copy);
 	else if (strcmp(key, "lxc.hook.start") == 0)
 		return add_hook(lxc_conf, LXCHOOK_START, copy);
+	else if (strcmp(key, "lxc.hook.stop") == 0)
+		return add_hook(lxc_conf, LXCHOOK_STOP, copy);
 	else if (strcmp(key, "lxc.hook.post-stop") == 0)
 		return add_hook(lxc_conf, LXCHOOK_POSTSTOP, copy);
 	else if (strcmp(key, "lxc.hook.clone") == 0)
-- 
2.1.4




More information about the lxc-devel mailing list