Commit 34662a68 authored by Evgeniy Akimov's avatar Evgeniy Akimov Committed by Pavel Emelyanov

cgroups: save freezer state during dump

CRIU sets freezer.state to "THAWED" during process tree dumping. That's why
we can't simply save freezer.state file contents to cgroups image. New
special function get_real_freezer_state() returns freezer cgroup state
observed before CRIU dumping start. Patch puts its return value to dump file.
Signed-off-by: 's avatarEvgeniy Akimov <geka666@gmail.com>
Signed-off-by: 's avatarEugene Batalov <eabatalov89@gmail.com>
Acked-by: 's avatarAndrew Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 25a978d3
......@@ -17,6 +17,7 @@
#include "imgset.h"
#include "util-pie.h"
#include "namespaces.h"
#include "seize.h"
#include "protobuf.h"
#include "protobuf/core.pb-c.h"
#include "protobuf/cgroup.pb-c.h"
......@@ -493,6 +494,36 @@ out:
return exit_code;
}
static int add_freezer_state(struct cg_controller *controller)
{
struct cgroup_dir *root_dir;
struct cgroup_prop *prop;
/*
* Here we rely on --freeze-cgroup option assumption that all tasks are in a
* specified freezer cgroup hierarchy, so we need to dump only one root freezer cgroup.
*/
if (!list_is_singular(&controller->heads)) {
pr_err("Should be only one root freezer cgroup");
return -1;
}
root_dir = list_first_entry(&controller->heads, struct cgroup_dir, siblings);
prop = create_cgroup_prop("freezer.state");
if (!prop)
return -1;
prop->value = xstrdup(get_real_freezer_state());
if (!prop->value) {
free_cgroup_prop(prop);
return -1;
}
list_add_tail(&prop->list, &root_dir->properties);
root_dir->n_properties++;
return 0;
}
static int collect_cgroups(struct list_head *ctls)
{
struct cg_ctl *cc;
......@@ -566,6 +597,10 @@ static int collect_cgroups(struct list_head *ctls)
if (ret < 0)
return ret;
if (opts.freeze_cgroup && !strcmp(cc->name, "freezer") &&
add_freezer_state(current_controller))
return -1;
}
return 0;
......
......@@ -3,5 +3,6 @@
extern int collect_pstree(pid_t pid);
extern void pstree_switch_state(struct pstree_item *root_item, int st);
extern const char *get_real_freezer_state(void);
#endif
......@@ -59,6 +59,11 @@ err:
static bool freezer_thawed;
const char *get_real_freezer_state(void)
{
return freezer_thawed ? thawed : frozen;
}
static int freezer_restore_state(void)
{
int fd;
......
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