Commit 773fb9ca by Serge Hallyn Committed by Stéphane Graber

replace HOOK define with proper code.

parent 8215fe8e
......@@ -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;
......
......@@ -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
......
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment