Skip to content

Commit

Permalink
conf: expose lxc_clear_cgroup2_devices()
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Feb 19, 2021
1 parent d6c0692 commit a7744f1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/lxc/conf.c
Expand Up @@ -3710,17 +3710,9 @@ int lxc_clear_cgroups(struct lxc_conf *c, const char *key, int version)
return 0;
}

static void lxc_clear_devices(struct lxc_conf *conf)
static inline void lxc_clear_cgroups_devices(struct lxc_conf *conf)
{
struct lxc_list *list = &(conf->bpf_devices).device_item;
struct lxc_list *it, *next;

lxc_list_for_each_safe(it, list, next) {
lxc_list_del(it);
free(it);
}

lxc_list_init(&(conf->bpf_devices).device_item);
lxc_clear_cgroup2_devices(&conf->bpf_devices);
}

int lxc_clear_limits(struct lxc_conf *c, const char *key)
Expand Down Expand Up @@ -3960,7 +3952,7 @@ void lxc_conf_free(struct lxc_conf *conf)
lxc_clear_config_keepcaps(conf);
lxc_clear_cgroups(conf, "lxc.cgroup", CGROUP_SUPER_MAGIC);
lxc_clear_cgroups(conf, "lxc.cgroup2", CGROUP2_SUPER_MAGIC);
lxc_clear_devices(conf);
lxc_clear_cgroups_devices(conf);
lxc_clear_hooks(conf, "lxc.hook");
lxc_clear_mount_entries(conf);
lxc_clear_idmaps(conf);
Expand Down
13 changes: 13 additions & 0 deletions src/lxc/conf.h
Expand Up @@ -570,4 +570,17 @@ static inline void put_lxc_rootfs(struct lxc_rootfs *rootfs, bool unpin)
}
}

static inline void lxc_clear_cgroup2_devices(struct bpf_devices *bpf_devices)
{
struct lxc_list *list = &bpf_devices->device_item;
struct lxc_list *it, *next;

lxc_list_for_each_safe (it, list, next) {
lxc_list_del(it);
free(it);
}

lxc_list_init(&bpf_devices->device_item);
}

#endif /* __LXC_CONF_H */

0 comments on commit a7744f1

Please sign in to comment.