*group = NULL;
newGroup = g_new0(virCgroup, 1);
- if (path[0] == '/' || !parent) {
- newGroup->path = g_strdup(path);
- } else {
- newGroup->path = g_strdup_printf("%s%s%s", parent->path,
- STREQ(parent->path, "") ? "" : "/", path);
- }
-
if (virCgroupDetect(newGroup, pid, controllers, path, parent) < 0)
return -1;
g_autofree char *keypath = NULL;
bool done = false;
FILE *fp = NULL;
- VIR_DEBUG("group=%p path=%s signum=%d pids=%p",
- group, group->path, signum, pids);
+ VIR_DEBUG("group=%p signum=%d pids=%p",
+ group, signum, pids);
if (virCgroupPathOfController(group, controller, taskFile, &keypath) < 0)
return -1;
g_autoptr(DIR) dp = NULL;
struct dirent *ent;
int direrr;
- VIR_DEBUG("group=%p path=%s signum=%d pids=%p",
- group, group->path, signum, pids);
+ VIR_DEBUG("group=%p signum=%d pids=%p",
+ group, signum, pids);
if (virCgroupPathOfController(group, controller, "", &keypath) < 0)
return -1;
virCgroupBackendPtr *backends = virCgroupBackendGetAll();
g_autoptr(GHashTable) pids = g_hash_table_new_full(g_int64_hash, g_int64_equal, g_free, NULL);
- VIR_DEBUG("group=%p path=%s signum=%d", group, group->path, signum);
+ VIR_DEBUG("group=%p signum=%d", group, signum);
for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
if (backends && backends[i] && backends[i]->available()) {
{
size_t i;
int ret;
- VIR_DEBUG("cgroup=%p path=%s", group, group->path);
+ VIR_DEBUG("cgroup=%p", group);
for (i = 0; i < 15; i++) {
int signum;
if (i == 0)
VIR_FREE(group->unified.mountPoint);
VIR_FREE(group->unified.placement);
- VIR_FREE(group->path);
VIR_FREE(group);
}
"cpuset.memory_migrate",
};
- VIR_DEBUG("Setting up inheritance %s -> %s", parent->path, group->path);
+ VIR_DEBUG("Setting up inheritance %s -> %s",
+ parent->legacy[VIR_CGROUP_CONTROLLER_CPUSET].placement,
+ group->legacy[VIR_CGROUP_CONTROLLER_CPUSET].placement);
for (i = 0; i < G_N_ELEMENTS(inherit_values); i++) {
g_autofree char *value = NULL;
if (value == 1)
return 0;
- VIR_DEBUG("Setting up %s/%s", group->path, filename);
if (virCgroupSetValueU64(group,
VIR_CGROUP_CONTROLLER_MEMORY,
filename, 1) < 0)
{
size_t i;
- VIR_DEBUG("Make group %s", group->path);
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
g_autofree char *path = NULL;
int rc = 0;
size_t i;
- VIR_DEBUG("Removing cgroup %s", group->path);
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
g_autofree char *grppath = NULL;
VIR_DEBUG("Removing cgroup %s and all child cgroups", grppath);
rc = virCgroupRemoveRecursively(grppath);
}
- VIR_DEBUG("Done removing cgroup %s", group->path);
return rc;
}
VIR_LOG_INIT("tests.cgrouptest");
static int validateCgroup(virCgroupPtr cgroup,
- const char *expectPath,
const char **expectMountPoint,
const char **expectLinkPoint,
const char **expectPlacement,
{
size_t i;
- if (STRNEQ(cgroup->path, expectPath)) {
- fprintf(stderr, "Wrong path '%s', expected '%s'\n",
- cgroup->path, expectPath);
- return -1;
- }
-
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
if (STRNEQ_NULLABLE(expectMountPoint[i],
cgroup->legacy[i].mountPoint)) {
return -1;
}
- return validateCgroup(cgroup, "", mountsFull, links, placement, NULL, NULL, 0);
+ return validateCgroup(cgroup, mountsFull, links, placement, NULL, NULL, 0);
}
fprintf(stderr, "Cannot create /virtualmachines cgroup: %d\n", -rv);
return -1;
}
- rv = validateCgroup(cgroup, "/virtualmachines.partition", mountsSmall, links, placementSmall, NULL, NULL, 0);
+ rv = validateCgroup(cgroup, mountsSmall, links, placementSmall, NULL, NULL, 0);
virCgroupFree(cgroup);
if ((rv = virCgroupNewPartition("/virtualmachines", true, -1, &cgroup)) != 0) {
fprintf(stderr, "Cannot create /virtualmachines cgroup: %d\n", -rv);
return -1;
}
- return validateCgroup(cgroup, "/virtualmachines.partition", mountsFull, links, placementFull, NULL, NULL, 0);
+ return validateCgroup(cgroup, mountsFull, links, placementFull, NULL, NULL, 0);
}
return -1;
}
- return validateCgroup(cgroup, "/deployment.partition/production.partition",
- mountsFull, links, placementFull, NULL, NULL, 0);
+ return validateCgroup(cgroup, mountsFull, links, placementFull, NULL, NULL, 0);
}
return -1;
}
- return validateCgroup(cgroup, "/user/berrange.user/production.partition",
- mountsFull, links, placementFull, NULL, NULL, 0);
+ return validateCgroup(cgroup, mountsFull, links, placementFull, NULL, NULL, 0);
}
return -1;
}
- return validateCgroup(domaincgroup, "/production.partition/foo.libvirt-lxc", mountsFull, links, placement, NULL, NULL, 0);
+ return validateCgroup(domaincgroup, mountsFull, links, placement, NULL, NULL, 0);
}
static int testCgroupNewForPartitionDomainEscaped(const void *args G_GNUC_UNUSED)
* since our fake /proc/cgroups pretends this controller
* isn't compiled into the kernel
*/
- return validateCgroup(domaincgroup, "/_cgroup.evil/net_cls.evil/__evil.evil/_cpu.foo.libvirt-lxc", mountsFull, links, placement, NULL, NULL, 0);
+ return validateCgroup(domaincgroup, mountsFull, links, placement, NULL, NULL, 0);
}
static int testCgroupNewForSelfAllInOne(const void *args G_GNUC_UNUSED)
return -1;
}
- return validateCgroup(cgroup, "", mountsAllInOne, linksAllInOne, placement, NULL, NULL, 0);
+ return validateCgroup(cgroup, mountsAllInOne, linksAllInOne, placement, NULL, NULL, 0);
}
return -1;
}
- return validateCgroup(cgroup, "", empty, empty, empty,
+ return validateCgroup(cgroup, empty, empty, empty,
"/not/really/sys/fs/cgroup", "/", controllers);
}
return -1;
}
- return validateCgroup(cgroup, "", mounts, empty, placement,
+ return validateCgroup(cgroup, mounts, empty, placement,
"/not/really/sys/fs/cgroup/unified", "/", controllers);
}