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

« back to all changes in this revision

Viewing changes to src/lxc/confile.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:
56
56
static int config_rootfs_mount(const char *, char *, struct lxc_conf *);
57
57
static int config_pivotdir(const char *, char *, struct lxc_conf *);
58
58
static int config_utsname(const char *, char *, struct lxc_conf *);
 
59
static int config_hook(const char *key, char *value, struct lxc_conf *lxc_conf);
59
60
static int config_network_type(const char *, char *, struct lxc_conf *);
60
61
static int config_network_flags(const char *, char *, struct lxc_conf *);
61
62
static int config_network_link(const char *, char *, struct lxc_conf *);
93
94
        { "lxc.rootfs",               config_rootfs               },
94
95
        { "lxc.pivotdir",             config_pivotdir             },
95
96
        { "lxc.utsname",              config_utsname              },
 
97
        { "lxc.hook.pre-start",       config_hook                 },
 
98
        { "lxc.hook.mount",           config_hook                 },
 
99
        { "lxc.hook.start",           config_hook                 },
 
100
        { "lxc.hook.post-stop",       config_hook                 },
96
101
        { "lxc.network.type",         config_network_type         },
97
102
        { "lxc.network.flags",        config_network_flags        },
98
103
        { "lxc.network.link",         config_network_link         },
586
591
        return -1;
587
592
}
588
593
 
 
594
static int add_hook(struct lxc_conf *lxc_conf, int which, char *hook)
 
595
{
 
596
        struct lxc_list *hooklist;
 
597
 
 
598
        hooklist = malloc(sizeof(*hooklist));
 
599
        if (!hooklist) {
 
600
                free(hook);
 
601
                return -1;
 
602
        }
 
603
        hooklist->elem = hook;
 
604
        lxc_list_add_tail(&lxc_conf->hooks[which], hooklist);
 
605
        return 0;
 
606
}
 
607
 
 
608
static int config_hook(const char *key, char *value,
 
609
                                 struct lxc_conf *lxc_conf)
 
610
{
 
611
        char *copy = strdup(value);
 
612
        if (!copy) {
 
613
                SYSERROR("failed to dup string '%s'", value);
 
614
                return -1;
 
615
        }
 
616
        if (strcmp(key, "lxc.hook.pre-start") == 0)
 
617
                return add_hook(lxc_conf, LXCHOOK_PRESTART, copy);
 
618
        else if (strcmp(key, "lxc.hook.mount") == 0)
 
619
                return add_hook(lxc_conf, LXCHOOK_MOUNT, copy);
 
620
        else if (strcmp(key, "lxc.hook.start") == 0)
 
621
                return add_hook(lxc_conf, LXCHOOK_START, copy);
 
622
        else if (strcmp(key, "lxc.hook.post-stop") == 0)
 
623
                return add_hook(lxc_conf, LXCHOOK_POSTSTOP, copy);
 
624
        SYSERROR("Unknown key: %s", key);
 
625
        free(copy);
 
626
        return -1;
 
627
}
 
628
 
589
629
static int config_personality(const char *key, char *value,
590
630
                              struct lxc_conf *lxc_conf)
591
631
{