2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 09:58:09 +00:00
criu/include/cgroup.h
Tycho Andersen 94f6c87c9f cg: add --cgroup-root option
The motivation for this is to be able to restore containers into cgroups other
than what they were dumped in (if, e.g. they might conflict with an existing
container). Suppose you have a container in:

memory:/mycontainer
cpuacct,cpu:/mycontainer
blkio:/mycontainer
name=systemd:/mycontainer

You could then restore them to /mycontainer2 via --cgroup-root /mycontainer2.
If you want to restore different controllers to different paths, you can
provide multiple arguments, for example, passing:

--cgroup-root /mycontainer2 --cgroup-root cpuacct,cpu:/specialcpu \
--cgroup-root name=systemd:/specialsystemd

Would result in things being restored to:

memory:/mycontainer2
cpuacct,cpu:/specialcpu
blkio:/mycontainer2
name=systemd:/specialsystemd

i.e. a --cgroup-root without a controller prefix specifies the new default root
for all cgroups.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-19 12:58:36 +04:00

60 lines
1.4 KiB
C

#ifndef __CR_CGROUP_H__
#define __CR_CGROUP_H__
#include "asm/int.h"
struct pstree_item;
extern u32 root_cg_set;
int dump_task_cgroup(struct pstree_item *, u32 *);
int dump_cgroups(void);
int prepare_task_cgroup(struct pstree_item *);
int prepare_cgroup(void);
/* Restore things like cpu_limit in known cgroups. */
int prepare_cgroup_properties(void);
void fini_cgroup(void);
struct cg_controller;
struct cgroup_prop {
char *name;
char *value;
struct list_head list;
};
/* This describes a particular cgroup path, e.g. the '/lxc/u1' part of
* 'blkio/lxc/u1' and any properties it has.
*/
struct cgroup_dir {
char *path;
struct list_head properties;
unsigned int n_properties;
/* this is how children are linked together */
struct list_head siblings;
/* more cgroup_dirs */
struct list_head children;
unsigned int n_children;
};
/* This describes a particular cgroup controller, e.g. blkio or cpuset.
* The heads are subdirectories organized in their tree format.
*/
struct cg_controller {
int heirarchy;
unsigned int n_controllers;
char **controllers;
/* cgroup_dirs */
struct list_head heads;
unsigned int n_heads;
/* for cgroup list in cgroup.c */
struct list_head l;
};
struct cg_controller *new_controller(const char *name, int heirarchy);
/* parse all global cgroup information into structures */
int parse_cg_info(void);
int new_cg_root_add(char *controller, char *newroot);
#endif /* __CR_CGROUP_H__ */