diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 8080d7d0b..b437654a3 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -2181,7 +2181,11 @@ int lxc_setup(const char *name, struct lxc_conf *lxc_conf) return -1; } - HOOK(name, "mount", lxc_conf); + if (run_lxc_hooks(name, "mount", lxc_conf)) { + ERROR("failed to run mount hooks for container '%s'.", name); + return -1; + } + if (setup_cgroup(name, &lxc_conf->cgroup)) { ERROR("failed to setup the cgroups for '%s'", name); return -1; diff --git a/src/lxc/conf.h b/src/lxc/conf.h index 7c1ded00f..eee12b7b5 100644 --- a/src/lxc/conf.h +++ b/src/lxc/conf.h @@ -232,12 +232,6 @@ struct lxc_conf { }; int run_lxc_hooks(const char *name, char *hook, struct lxc_conf *conf); -/* we don't want to stick with the HOOK define, it's just to easily start */ -#define HOOK(name, which, conf) \ - do { \ - int hookret = run_lxc_hooks(name, which, conf); \ - if (hookret) return -1; \ - } while (0); /* * Initialize the lxc configuration structure diff --git a/src/lxc/start.c b/src/lxc/start.c index 48e9962e7..19815fcab 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -359,7 +359,10 @@ struct lxc_handler *lxc_init(const char *name, struct lxc_conf *conf) goto out_free_name; } - HOOK(name, "pre-start", conf); + if (run_lxc_hooks(name, "pre-start", conf)) { + ERROR("failed to run pre-start hooks for container '%s'.", name); + goto out_aborting; + } if (lxc_create_tty(name, conf)) { ERROR("failed to create the ttys"); @@ -405,7 +408,8 @@ void lxc_fini(const char *name, struct lxc_handler *handler) lxc_set_state(name, handler, STOPPING); lxc_set_state(name, handler, STOPPED); - HOOK(name, "post-stop", handler->conf); + if (run_lxc_hooks(name, "post-stop", handler->conf)) + ERROR("failed to run post-stop hooks for container '%s'.", name); /* reset mask set by setup_signal_fd */ if (sigprocmask(SIG_SETMASK, &handler->oldmask, NULL)) @@ -526,9 +530,12 @@ static int do_start(void *data) if (apparmor_load(handler) < 0) goto out_warn_father; - close(handler->sigfd); + if (run_lxc_hooks(handler->name, "start", handler->conf)) { + ERROR("failed to run start hooks for container '%s'.", handler->name); + goto out_warn_father; + } - HOOK(handler->name, "start", handler->conf); + close(handler->sigfd); /* after this call, we are in error because this * ops should not return as it execs */