]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vircgroup: remove useless cgroup->path variable
authorPavel Hrdina <phrdina@redhat.com>
Wed, 14 Oct 2020 08:29:45 +0000 (10:29 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Tue, 3 Nov 2020 20:26:32 +0000 (21:26 +0100)
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>
src/util/vircgroup.c
src/util/vircgrouppriv.h
src/util/vircgroupv1.c
src/util/vircgroupv2.c
tests/vircgrouptest.c

index e3c45e93cb12c8acaecdc9a3dd4732d76b5ef3e2..7ff23e1218e12fc51450956b56c6fa4c461ed518 100644 (file)
@@ -669,13 +669,6 @@ virCgroupNew(pid_t pid,
     *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;
 
@@ -2388,8 +2381,8 @@ virCgroupKillInternal(virCgroupPtr group,
     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;
@@ -2471,8 +2464,8 @@ virCgroupKillRecursiveInternal(virCgroupPtr group,
     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;
@@ -2532,7 +2525,7 @@ virCgroupKillRecursive(virCgroupPtr group, int signum)
     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()) {
@@ -2563,7 +2556,7 @@ virCgroupKillPainfully(virCgroupPtr group)
 {
     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)
@@ -3491,7 +3484,6 @@ virCgroupFree(virCgroupPtr group)
     VIR_FREE(group->unified.mountPoint);
     VIR_FREE(group->unified.placement);
 
-    VIR_FREE(group->path);
     VIR_FREE(group);
 }
 
index f85a36efdb940a04c100c62faef12dd5c4e5968f..af8bf998884ae25278821a1a1c86b8430639665b 100644 (file)
@@ -60,8 +60,6 @@ typedef struct _virCgroupV2Controller virCgroupV2Controller;
 typedef virCgroupV2Controller *virCgroupV2ControllerPtr;
 
 struct _virCgroup {
-    char *path;
-
     virCgroupBackendPtr backends[VIR_CGROUP_BACKEND_TYPE_LAST];
 
     virCgroupV1Controller legacy[VIR_CGROUP_CONTROLLER_LAST];
index 61fb359f8db58d2c5b09a85224574be681a3c3e5..6bb819410b0849e89e60c3c7aaad91195cd37682 100644 (file)
@@ -545,7 +545,9 @@ virCgroupV1CpuSetInherit(virCgroupPtr parent,
         "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;
 
@@ -583,7 +585,6 @@ virCgroupV1SetMemoryUseHierarchy(virCgroupPtr group)
     if (value == 1)
         return 0;
 
-    VIR_DEBUG("Setting up %s/%s", group->path, filename);
     if (virCgroupSetValueU64(group,
                              VIR_CGROUP_CONTROLLER_MEMORY,
                              filename, 1) < 0)
@@ -601,7 +602,6 @@ virCgroupV1MakeGroup(virCgroupPtr parent,
 {
     size_t i;
 
-    VIR_DEBUG("Make group %s", group->path);
     for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
         g_autofree char *path = NULL;
 
@@ -671,7 +671,6 @@ virCgroupV1Remove(virCgroupPtr group)
     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;
 
@@ -697,7 +696,6 @@ virCgroupV1Remove(virCgroupPtr group)
         VIR_DEBUG("Removing cgroup %s and all child cgroups", grppath);
         rc = virCgroupRemoveRecursively(grppath);
     }
-    VIR_DEBUG("Done removing cgroup %s", group->path);
 
     return rc;
 }
index 530e5d2ce9fa6719a2bb6fda2a29663455320e48..0467a725666d4b9b2a59999a56549f801fdcf7fd 100644 (file)
@@ -413,8 +413,6 @@ virCgroupV2MakeGroup(virCgroupPtr parent,
         return 0;
     }
 
-    VIR_DEBUG("Make group %s", group->path);
-
     controller = virCgroupV2GetAnyController(group);
     if (virCgroupV2PathOfController(group, controller, "", &path) < 0)
         return -1;
@@ -424,7 +422,7 @@ virCgroupV2MakeGroup(virCgroupPtr parent,
     if (!virFileExists(path) &&
         (!create || (mkdir(path, 0755) < 0 && errno != EEXIST))) {
         virReportSystemError(errno, _("Failed to create v2 cgroup '%s'"),
-                             group->path);
+                             path);
         return -1;
     }
 
index 6c1a766fa20f84019a2a683137c20cd98fbb588b..0dd5e3f0b46b1eb485c12e2f2f91bd0e59b42cd6 100644 (file)
@@ -38,7 +38,6 @@
 VIR_LOG_INIT("tests.cgrouptest");
 
 static int validateCgroup(virCgroupPtr cgroup,
-                          const char *expectPath,
                           const char **expectMountPoint,
                           const char **expectLinkPoint,
                           const char **expectPlacement,
@@ -48,12 +47,6 @@ static int validateCgroup(virCgroupPtr cgroup,
 {
     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)) {
@@ -240,7 +233,7 @@ static int testCgroupNewForSelf(const void *args G_GNUC_UNUSED)
         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);
         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);
 }
 
 
@@ -365,8 +358,7 @@ static int testCgroupNewForPartitionNested(const void *args G_GNUC_UNUSED)
         return -1;
     }
 
-    return validateCgroup(cgroup, "/deployment.partition/production.partition",
-                          mountsFull, links, placementFull, NULL, NULL, 0);
+    return validateCgroup(cgroup, mountsFull, links, placementFull, NULL, NULL, 0);
 }
 
 
@@ -416,8 +408,7 @@ static int testCgroupNewForPartitionNestedDeep(const void *args G_GNUC_UNUSED)
         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);
 }
 
 
@@ -448,7 +439,7 @@ static int testCgroupNewForPartitionDomain(const void *args G_GNUC_UNUSED)
         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)
@@ -493,7 +484,7 @@ 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)
@@ -514,7 +505,7 @@ 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);
 }
 
 
@@ -547,7 +538,7 @@ static int testCgroupNewForSelfUnified(const void *args G_GNUC_UNUSED)
         return -1;
     }
 
-    return validateCgroup(cgroup, "", empty, empty, empty,
+    return validateCgroup(cgroup, empty, empty, empty,
                           "/not/really/sys/fs/cgroup", "/", controllers);
 }
 
@@ -580,7 +571,7 @@ static int testCgroupNewForSelfHybrid(const void *args G_GNUC_UNUSED)
         return -1;
     }
 
-    return validateCgroup(cgroup, "", mounts, empty, placement,
+    return validateCgroup(cgroup, mounts, empty, placement,
                           "/not/really/sys/fs/cgroup/unified", "/", controllers);
 }