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>
This commit is contained in:
Tycho Andersen 2014-08-15 17:02:21 -05:00 committed by Pavel Emelyanov
parent 513b0dc3e0
commit 94f6c87c9f
4 changed files with 119 additions and 1 deletions

View file

@ -55,5 +55,5 @@ 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__ */

View file

@ -19,6 +19,12 @@ struct script {
#define CPU_CAP_FPU (1u)
#define CPU_CAP_ALL (-1u)
struct cg_root_opt {
struct list_head node;
char *controller;
char *newroot;
};
struct cr_options {
int final_state;
char *show_dump_file;
@ -52,6 +58,8 @@ struct cr_options {
bool force_irmap;
char **exec_cmd;
bool manage_cgroups;
char *new_global_cg_root;
struct list_head new_cgroup_roots;
};
extern struct cr_options opts;