]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
Convert LXC driver to use virCgroupNewMachine
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 22 Jul 2013 16:11:09 +0000 (17:11 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 25 Jul 2013 10:42:48 +0000 (11:42 +0100)
Convert the LXC driver code to use the new atomic API
for setup of cgroups

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/lxc/lxc_cgroup.c
src/lxc/lxc_controller.c

index d9e9e0d4c68fac4be9ee6040b53c7d8169104159..af91b049aff91533bd8724e03193a2f2c6828030 100644 (file)
@@ -431,7 +431,6 @@ cleanup:
 
 virCgroupPtr virLXCCgroupCreate(virDomainDefPtr def)
 {
-    virCgroupPtr parent = NULL;
     virCgroupPtr cgroup = NULL;
 
     if (!def->resource) {
@@ -454,46 +453,26 @@ virCgroupPtr virLXCCgroupCreate(virDomainDefPtr def)
                        def->resource->partition);
         goto cleanup;
     }
-    /* We only auto-create the default partition. In other
-     * cases we expect the sysadmin/app to have done so */
-    if (virCgroupNewPartition(def->resource->partition,
-                              STREQ(def->resource->partition, "/machine"),
-                              -1,
-                              &parent) < 0)
-        goto cleanup;
 
-    if (virCgroupNewDomainPartition(parent,
-                                    "lxc",
-                                    def->name,
-                                    true,
-                                    &cgroup) < 0)
+    /*
+     * XXX
+     * We should pass the PID of the LXC init process
+     * not ourselves, but this requires some more
+     * refactoring. We should also pass the root dir
+     */
+    if (virCgroupNewMachine(def->name,
+                            "lxc",
+                            true,
+                            def->uuid,
+                            NULL,
+                            getpid(),
+                            true,
+                            def->resource->partition,
+                            -1,
+                            &cgroup) < 0)
         goto cleanup;
 
 cleanup:
-    virCgroupFree(&parent);
-    return cgroup;
-}
-
-
-virCgroupPtr virLXCCgroupJoin(virDomainDefPtr def)
-{
-    virCgroupPtr cgroup = NULL;
-    int ret = -1;
-
-    if (!(cgroup = virLXCCgroupCreate(def)))
-        return NULL;
-
-    if (virCgroupAddTask(cgroup, getpid()) < 0)
-        goto cleanup;
-
-    ret = 0;
-
-cleanup:
-    if (ret < 0) {
-        virCgroupFree(&cgroup);
-        return NULL;
-    }
-
     return cgroup;
 }
 
index bbec34422b5cfe091f1f084486d68aa6d5a6d0bd..124ab192844ccf690e8cfe0a9e7811066c697d45 100644 (file)
@@ -2388,7 +2388,7 @@ int main(int argc, char *argv[])
     if (virLXCControllerValidateConsoles(ctrl) < 0)
         goto cleanup;
 
-    if (!(ctrl->cgroup = virLXCCgroupJoin(ctrl->def)))
+    if (!(ctrl->cgroup = virLXCCgroupCreate(ctrl->def)))
         goto cleanup;
 
     if (virLXCControllerSetupServer(ctrl) < 0)