~serge-hallyn/ubuntu/quantal/lxc/lxc-user-ns

« back to all changes in this revision

Viewing changes to src/lxc/conf.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn, Stéphane Graber, Serge Hallyn
  • Date: 2012-06-26 13:04:01 UTC
  • Revision ID: package-import@ubuntu.com-20120626130401-8tclzscid8u2lzxu
Tags: 0.8.0~rc1-4ubuntu17
[ Stéphane Graber ]
* 0090-lxc-ubuntu-use-dpkg-add-architecture: Update lxc-ubuntu
  template to use "dpkg --add-architecture" in containers running
  dpkg >= 1.16.2. (LP: #1017862)

[ Serge Hallyn ]
* 0091-introduce-container-hooks.patch: introduce container hooks at several
  points in the container life-cycle.
* Add copyright statement to lxc-aa-custom-profile
* Add debian/hooks/mountcgroups as an example (installed under
  /usr/share/lxc/hooks)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1689
1689
struct lxc_conf *lxc_conf_init(void)
1690
1690
{
1691
1691
        struct lxc_conf *new;
 
1692
        int i;
1692
1693
 
1693
1694
        new =   malloc(sizeof(*new));
1694
1695
        if (!new) {
1710
1711
        lxc_list_init(&new->mount_list);
1711
1712
        lxc_list_init(&new->caps);
1712
1713
        new->aa_profile = NULL;
 
1714
        for (i=0; i<NUM_LXC_HOOKS; i++)
 
1715
                lxc_list_init(&new->hooks[i]);
1713
1716
 
1714
1717
        return new;
1715
1718
}
2186
2189
                ERROR("failed to setup the cgroups for '%s'", name);
2187
2190
                return -1;
2188
2191
        }
 
2192
        HOOK(name, "mount", lxc_conf);
2189
2193
 
2190
2194
        if (setup_console(&lxc_conf->rootfs, &lxc_conf->console, lxc_conf->ttydir)) {
2191
2195
                ERROR("failed to setup the console for '%s'", name);
2238
2242
 
2239
2243
        return 0;
2240
2244
}
 
2245
 
 
2246
int run_lxc_hooks(const char *name, char *hook, struct lxc_conf *conf)
 
2247
{
 
2248
        int which = -1;
 
2249
        struct lxc_list *it;
 
2250
 
 
2251
        if (strcmp(hook, "pre-start") == 0)
 
2252
                which = LXCHOOK_PRESTART;
 
2253
        else if (strcmp(hook, "mount") == 0)
 
2254
                which = LXCHOOK_MOUNT;
 
2255
        else if (strcmp(hook, "start") == 0)
 
2256
                which = LXCHOOK_START;
 
2257
        else if (strcmp(hook, "post-stop") == 0)
 
2258
                which = LXCHOOK_POSTSTOP;
 
2259
        else
 
2260
                return -1;
 
2261
        lxc_list_for_each(it, &conf->hooks[which]) {
 
2262
                int ret;
 
2263
                char *hookname = it->elem;
 
2264
                ret = run_script(name, "lxc", hookname, hook, NULL);
 
2265
                if (ret)
 
2266
                        return ret;
 
2267
        }
 
2268
        return 0;
 
2269
}