2
0
mirror of git://github.com/lxc/lxc synced 2025-08-31 21:57:59 +00:00

cgroup: get rid of weird hack in cgfsng_escape

We initialized cgfsng in a strange way inside of its implementation of
escape so we could use it during checkpoint. Instead, the previous patch
does a hacky initialization in criu.c, and we can get rid of the hacks
elsewhere :)

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
This commit is contained in:
Tycho Andersen
2016-09-14 14:53:21 +00:00
parent 0ab5703fcf
commit 6df334d158

View File

@@ -1426,19 +1426,11 @@ static int cgfsng_nrtasks(void *hdata) {
/* Only root needs to escape to the cgroup of its init */ /* Only root needs to escape to the cgroup of its init */
static bool cgfsng_escape() static bool cgfsng_escape()
{ {
struct cgfsng_handler_data *d;
int i; int i;
bool ret = false;
if (geteuid()) if (geteuid())
return true; return true;
d = cgfsng_init("criu-temp-cgfsng");
if (!d) {
ERROR("cgfsng_init failed");
return false;
}
for (i = 0; hierarchies[i]; i++) { for (i = 0; hierarchies[i]; i++) {
char *fullpath = must_make_path(hierarchies[i]->mountpoint, char *fullpath = must_make_path(hierarchies[i]->mountpoint,
hierarchies[i]->base_cgroup, hierarchies[i]->base_cgroup,
@@ -1446,15 +1438,12 @@ static bool cgfsng_escape()
if (lxc_write_to_file(fullpath, "0", 2, false) != 0) { if (lxc_write_to_file(fullpath, "0", 2, false) != 0) {
SYSERROR("Failed to escape to %s", fullpath); SYSERROR("Failed to escape to %s", fullpath);
free(fullpath); free(fullpath);
goto out; return false;
} }
free(fullpath); free(fullpath);
} }
ret = true; return true;
out:
free_handler_data(d);
return ret;
} }
static int cgfsng_num_hierarchies(void) static int cgfsng_num_hierarchies(void)