[libvirt] [PATCH v2 RESEND 1/2] refactor virCgroupDetectMounts and virCgroupDetectPlacement

Hu Tao hutao at cn.fujitsu.com
Fri Feb 8 02:16:26 UTC 2013


---
 src/util/vircgroup.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 48cba93..71d46c5 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -113,7 +113,7 @@ bool virCgroupMounted(virCgroupPtr cgroup, int controller)
  * Process /proc/mounts figuring out what controllers are
  * mounted and where
  */
-static int virCgroupDetectMounts(virCgroupPtr group)
+static int virCgroupDetectMounts(struct virCgroupController (*controllers)[VIR_CGROUP_CONTROLLER_LAST])
 {
     int i;
     FILE *mounts = NULL;
@@ -148,8 +148,8 @@ static int virCgroupDetectMounts(virCgroupPtr group)
                  * first entry only
                  */
                 if (typelen == len && STREQLEN(typestr, tmp, len) &&
-                    !group->controllers[i].mountPoint &&
-                    !(group->controllers[i].mountPoint = strdup(entry.mnt_dir)))
+                    !(*controllers)[i].mountPoint &&
+                    !((*controllers)[i].mountPoint = strdup(entry.mnt_dir)))
                     goto no_memory;
                 tmp = next;
             }
@@ -171,7 +171,7 @@ no_memory:
  * sub-path the current process is assigned to. ie not
  * necessarily in the root
  */
-static int virCgroupDetectPlacement(virCgroupPtr group)
+static int virCgroupDetectPlacement(struct virCgroupController (*cgroupControllers)[VIR_CGROUP_CONTROLLER_LAST])
 {
     int i;
     FILE *mapping  = NULL;
@@ -212,7 +212,7 @@ static int virCgroupDetectPlacement(virCgroupPtr group)
                     len = strlen(tmp);
                 }
                 if (typelen == len && STREQLEN(typestr, tmp, len) &&
-                    !(group->controllers[i].placement = strdup(STREQ(path, "/") ? "" : path)))
+                    !((*cgroupControllers)[i].placement = strdup(STREQ(path, "/") ? "" : path)))
                     goto no_memory;
 
                 tmp = next;
@@ -236,7 +236,7 @@ static int virCgroupDetect(virCgroupPtr group)
     int rc;
     int i;
 
-    rc = virCgroupDetectMounts(group);
+    rc = virCgroupDetectMounts(&group->controllers);
     if (rc < 0) {
         VIR_ERROR(_("Failed to detect mounts for %s"), group->path);
         return rc;
@@ -251,7 +251,7 @@ static int virCgroupDetect(virCgroupPtr group)
         return -ENXIO;
 
 
-    rc = virCgroupDetectPlacement(group);
+    rc = virCgroupDetectPlacement(&group->controllers);
 
     if (rc == 0) {
         /* Check that for every mounted controller, we found our placement */
-- 
1.8.0.1.240.ge8a1f5a




More information about the libvir-list mailing list