Commit 17ed13a3 by Serge Hallyn Committed by Stéphane Graber

Support individual hook types in clear_config_item

Without this patch, only clear_config_item("lxc.hook") works. Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent f6144ed4
......@@ -2542,18 +2542,31 @@ int lxc_clear_mount_entries(struct lxc_conf *c)
return 0;
}
int lxc_clear_hooks(struct lxc_conf *c)
int lxc_clear_hooks(struct lxc_conf *c, char *key)
{
struct lxc_list *it;
bool all = false, done = false;
char *k = key + 9;
int i;
if (strcmp(key, "lxc.hook") == 0)
all = true;
for (i=0; i<NUM_LXC_HOOKS; i++) {
lxc_list_for_each(it, &c->hooks[i]) {
lxc_list_del(it);
free(it->elem);
free(it);
if (all || strcmp(k, lxchook_names[i]) == 0) {
lxc_list_for_each(it, &c->hooks[i]) {
lxc_list_del(it);
free(it->elem);
free(it);
}
done = true;
}
}
if (!done) {
ERROR("Invalid hook key: %s", key);
return -1;
}
return 0;
}
......@@ -2572,7 +2585,7 @@ void lxc_conf_free(struct lxc_conf *conf)
#endif
lxc_clear_config_caps(conf);
lxc_clear_cgroups(conf, "lxc.cgroup");
lxc_clear_hooks(conf);
lxc_clear_hooks(conf, "lxc.hook");
lxc_clear_mount_entries(conf);
free(conf);
}
......@@ -262,7 +262,7 @@ extern int lxc_clear_nic(struct lxc_conf *c, char *key);
extern int lxc_clear_config_caps(struct lxc_conf *c);
extern int lxc_clear_cgroups(struct lxc_conf *c, char *key);
extern int lxc_clear_mount_entries(struct lxc_conf *c);
extern int lxc_clear_hooks(struct lxc_conf *c);
extern int lxc_clear_hooks(struct lxc_conf *c, char *key);
/*
* Configure the container from inside
......
......@@ -1568,8 +1568,8 @@ int lxc_clear_config_item(struct lxc_conf *c, char *key)
return lxc_clear_cgroups(c, key);
else if (strcmp(key, "lxc.mount.entries") == 0)
return lxc_clear_mount_entries(c);
else if (strcmp(key, "lxc.hook") == 0)
return lxc_clear_hooks(c);
else if (strncmp(key, "lxc.hook", 8) == 0)
return lxc_clear_hooks(c, key);
return -1;
}
......
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