mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
vircgroup: remove useless cgroup->path variable
It is only used for debug and error purposes which can be easily replaced by @placement. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
9d312af357
commit
c88b3712ca
@ -669,13 +669,6 @@ virCgroupNew(pid_t pid,
|
|||||||
*group = NULL;
|
*group = NULL;
|
||||||
newGroup = g_new0(virCgroup, 1);
|
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)
|
if (virCgroupDetect(newGroup, pid, controllers, path, parent) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -2388,8 +2381,8 @@ virCgroupKillInternal(virCgroupPtr group,
|
|||||||
g_autofree char *keypath = NULL;
|
g_autofree char *keypath = NULL;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
VIR_DEBUG("group=%p path=%s signum=%d pids=%p",
|
VIR_DEBUG("group=%p signum=%d pids=%p",
|
||||||
group, group->path, signum, pids);
|
group, signum, pids);
|
||||||
|
|
||||||
if (virCgroupPathOfController(group, controller, taskFile, &keypath) < 0)
|
if (virCgroupPathOfController(group, controller, taskFile, &keypath) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -2471,8 +2464,8 @@ virCgroupKillRecursiveInternal(virCgroupPtr group,
|
|||||||
g_autoptr(DIR) dp = NULL;
|
g_autoptr(DIR) dp = NULL;
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
int direrr;
|
int direrr;
|
||||||
VIR_DEBUG("group=%p path=%s signum=%d pids=%p",
|
VIR_DEBUG("group=%p signum=%d pids=%p",
|
||||||
group, group->path, signum, pids);
|
group, signum, pids);
|
||||||
|
|
||||||
if (virCgroupPathOfController(group, controller, "", &keypath) < 0)
|
if (virCgroupPathOfController(group, controller, "", &keypath) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -2532,7 +2525,7 @@ virCgroupKillRecursive(virCgroupPtr group, int signum)
|
|||||||
virCgroupBackendPtr *backends = virCgroupBackendGetAll();
|
virCgroupBackendPtr *backends = virCgroupBackendGetAll();
|
||||||
g_autoptr(GHashTable) pids = g_hash_table_new_full(g_int64_hash, g_int64_equal, g_free, NULL);
|
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++) {
|
for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
||||||
if (backends && backends[i] && backends[i]->available()) {
|
if (backends && backends[i] && backends[i]->available()) {
|
||||||
@ -2563,7 +2556,7 @@ virCgroupKillPainfully(virCgroupPtr group)
|
|||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret;
|
int ret;
|
||||||
VIR_DEBUG("cgroup=%p path=%s", group, group->path);
|
VIR_DEBUG("cgroup=%p", group);
|
||||||
for (i = 0; i < 15; i++) {
|
for (i = 0; i < 15; i++) {
|
||||||
int signum;
|
int signum;
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
@ -3491,7 +3484,6 @@ virCgroupFree(virCgroupPtr group)
|
|||||||
VIR_FREE(group->unified.mountPoint);
|
VIR_FREE(group->unified.mountPoint);
|
||||||
VIR_FREE(group->unified.placement);
|
VIR_FREE(group->unified.placement);
|
||||||
|
|
||||||
VIR_FREE(group->path);
|
|
||||||
VIR_FREE(group);
|
VIR_FREE(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,8 +60,6 @@ typedef struct _virCgroupV2Controller virCgroupV2Controller;
|
|||||||
typedef virCgroupV2Controller *virCgroupV2ControllerPtr;
|
typedef virCgroupV2Controller *virCgroupV2ControllerPtr;
|
||||||
|
|
||||||
struct _virCgroup {
|
struct _virCgroup {
|
||||||
char *path;
|
|
||||||
|
|
||||||
virCgroupBackendPtr backends[VIR_CGROUP_BACKEND_TYPE_LAST];
|
virCgroupBackendPtr backends[VIR_CGROUP_BACKEND_TYPE_LAST];
|
||||||
|
|
||||||
virCgroupV1Controller legacy[VIR_CGROUP_CONTROLLER_LAST];
|
virCgroupV1Controller legacy[VIR_CGROUP_CONTROLLER_LAST];
|
||||||
|
@ -545,7 +545,9 @@ virCgroupV1CpuSetInherit(virCgroupPtr parent,
|
|||||||
"cpuset.memory_migrate",
|
"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++) {
|
for (i = 0; i < G_N_ELEMENTS(inherit_values); i++) {
|
||||||
g_autofree char *value = NULL;
|
g_autofree char *value = NULL;
|
||||||
|
|
||||||
@ -583,7 +585,6 @@ virCgroupV1SetMemoryUseHierarchy(virCgroupPtr group)
|
|||||||
if (value == 1)
|
if (value == 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
VIR_DEBUG("Setting up %s/%s", group->path, filename);
|
|
||||||
if (virCgroupSetValueU64(group,
|
if (virCgroupSetValueU64(group,
|
||||||
VIR_CGROUP_CONTROLLER_MEMORY,
|
VIR_CGROUP_CONTROLLER_MEMORY,
|
||||||
filename, 1) < 0)
|
filename, 1) < 0)
|
||||||
@ -601,7 +602,6 @@ virCgroupV1MakeGroup(virCgroupPtr parent,
|
|||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
VIR_DEBUG("Make group %s", group->path);
|
|
||||||
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
||||||
g_autofree char *path = NULL;
|
g_autofree char *path = NULL;
|
||||||
|
|
||||||
@ -671,7 +671,6 @@ virCgroupV1Remove(virCgroupPtr group)
|
|||||||
int rc = 0;
|
int rc = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
VIR_DEBUG("Removing cgroup %s", group->path);
|
|
||||||
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
||||||
g_autofree char *grppath = NULL;
|
g_autofree char *grppath = NULL;
|
||||||
|
|
||||||
@ -697,7 +696,6 @@ virCgroupV1Remove(virCgroupPtr group)
|
|||||||
VIR_DEBUG("Removing cgroup %s and all child cgroups", grppath);
|
VIR_DEBUG("Removing cgroup %s and all child cgroups", grppath);
|
||||||
rc = virCgroupRemoveRecursively(grppath);
|
rc = virCgroupRemoveRecursively(grppath);
|
||||||
}
|
}
|
||||||
VIR_DEBUG("Done removing cgroup %s", group->path);
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -413,8 +413,6 @@ virCgroupV2MakeGroup(virCgroupPtr parent,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_DEBUG("Make group %s", group->path);
|
|
||||||
|
|
||||||
controller = virCgroupV2GetAnyController(group);
|
controller = virCgroupV2GetAnyController(group);
|
||||||
if (virCgroupV2PathOfController(group, controller, "", &path) < 0)
|
if (virCgroupV2PathOfController(group, controller, "", &path) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -424,7 +422,7 @@ virCgroupV2MakeGroup(virCgroupPtr parent,
|
|||||||
if (!virFileExists(path) &&
|
if (!virFileExists(path) &&
|
||||||
(!create || (mkdir(path, 0755) < 0 && errno != EEXIST))) {
|
(!create || (mkdir(path, 0755) < 0 && errno != EEXIST))) {
|
||||||
virReportSystemError(errno, _("Failed to create v2 cgroup '%s'"),
|
virReportSystemError(errno, _("Failed to create v2 cgroup '%s'"),
|
||||||
group->path);
|
path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
VIR_LOG_INIT("tests.cgrouptest");
|
VIR_LOG_INIT("tests.cgrouptest");
|
||||||
|
|
||||||
static int validateCgroup(virCgroupPtr cgroup,
|
static int validateCgroup(virCgroupPtr cgroup,
|
||||||
const char *expectPath,
|
|
||||||
const char **expectMountPoint,
|
const char **expectMountPoint,
|
||||||
const char **expectLinkPoint,
|
const char **expectLinkPoint,
|
||||||
const char **expectPlacement,
|
const char **expectPlacement,
|
||||||
@ -48,12 +47,6 @@ static int validateCgroup(virCgroupPtr cgroup,
|
|||||||
{
|
{
|
||||||
size_t i;
|
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++) {
|
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
||||||
if (STRNEQ_NULLABLE(expectMountPoint[i],
|
if (STRNEQ_NULLABLE(expectMountPoint[i],
|
||||||
cgroup->legacy[i].mountPoint)) {
|
cgroup->legacy[i].mountPoint)) {
|
||||||
@ -240,7 +233,7 @@ static int testCgroupNewForSelf(const void *args G_GNUC_UNUSED)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return validateCgroup(cgroup, "", mountsFull, links, placement, NULL, NULL, 0);
|
return validateCgroup(cgroup, mountsFull, links, placement, NULL, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -314,14 +307,14 @@ static int testCgroupNewForPartition(const void *args G_GNUC_UNUSED)
|
|||||||
fprintf(stderr, "Cannot create /virtualmachines cgroup: %d\n", -rv);
|
fprintf(stderr, "Cannot create /virtualmachines cgroup: %d\n", -rv);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
rv = validateCgroup(cgroup, "/virtualmachines.partition", mountsSmall, links, placementSmall, NULL, NULL, 0);
|
rv = validateCgroup(cgroup, mountsSmall, links, placementSmall, NULL, NULL, 0);
|
||||||
virCgroupFree(cgroup);
|
virCgroupFree(cgroup);
|
||||||
|
|
||||||
if ((rv = virCgroupNewPartition("/virtualmachines", true, -1, &cgroup)) != 0) {
|
if ((rv = virCgroupNewPartition("/virtualmachines", true, -1, &cgroup)) != 0) {
|
||||||
fprintf(stderr, "Cannot create /virtualmachines cgroup: %d\n", -rv);
|
fprintf(stderr, "Cannot create /virtualmachines cgroup: %d\n", -rv);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return validateCgroup(cgroup, "/virtualmachines.partition", mountsFull, links, placementFull, NULL, NULL, 0);
|
return validateCgroup(cgroup, mountsFull, links, placementFull, NULL, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -365,8 +358,7 @@ static int testCgroupNewForPartitionNested(const void *args G_GNUC_UNUSED)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return validateCgroup(cgroup, "/deployment.partition/production.partition",
|
return validateCgroup(cgroup, mountsFull, links, placementFull, NULL, NULL, 0);
|
||||||
mountsFull, links, placementFull, NULL, NULL, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -416,8 +408,7 @@ static int testCgroupNewForPartitionNestedDeep(const void *args G_GNUC_UNUSED)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return validateCgroup(cgroup, "/user/berrange.user/production.partition",
|
return validateCgroup(cgroup, mountsFull, links, placementFull, NULL, NULL, 0);
|
||||||
mountsFull, links, placementFull, NULL, NULL, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -448,7 +439,7 @@ static int testCgroupNewForPartitionDomain(const void *args G_GNUC_UNUSED)
|
|||||||
return -1;
|
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)
|
static int testCgroupNewForPartitionDomainEscaped(const void *args G_GNUC_UNUSED)
|
||||||
@ -493,7 +484,7 @@ static int testCgroupNewForPartitionDomainEscaped(const void *args G_GNUC_UNUSED
|
|||||||
* since our fake /proc/cgroups pretends this controller
|
* since our fake /proc/cgroups pretends this controller
|
||||||
* isn't compiled into the kernel
|
* 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)
|
static int testCgroupNewForSelfAllInOne(const void *args G_GNUC_UNUSED)
|
||||||
@ -514,7 +505,7 @@ static int testCgroupNewForSelfAllInOne(const void *args G_GNUC_UNUSED)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return validateCgroup(cgroup, "", mountsAllInOne, linksAllInOne, placement, NULL, NULL, 0);
|
return validateCgroup(cgroup, mountsAllInOne, linksAllInOne, placement, NULL, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -547,7 +538,7 @@ static int testCgroupNewForSelfUnified(const void *args G_GNUC_UNUSED)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return validateCgroup(cgroup, "", empty, empty, empty,
|
return validateCgroup(cgroup, empty, empty, empty,
|
||||||
"/not/really/sys/fs/cgroup", "/", controllers);
|
"/not/really/sys/fs/cgroup", "/", controllers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -580,7 +571,7 @@ static int testCgroupNewForSelfHybrid(const void *args G_GNUC_UNUSED)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return validateCgroup(cgroup, "", mounts, empty, placement,
|
return validateCgroup(cgroup, mounts, empty, placement,
|
||||||
"/not/really/sys/fs/cgroup/unified", "/", controllers);
|
"/not/really/sys/fs/cgroup/unified", "/", controllers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user