]> git.proxmox.com Git - mirror_lxc.git/commitdiff
implement cgmanager nrtasks
authorDwight Engen <dwight.engen@oracle.com>
Thu, 6 Feb 2014 20:38:04 +0000 (15:38 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 6 Feb 2014 21:26:30 +0000 (16:26 -0500)
This op will be used on older kernels where container shutdown via reboot(2)
is not implemented and we use the utmp watching code.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/cgmanager.c

index 6798b6b84261491b00b9bcfac62ba00aefbce4e5..37f4eb39cef871ec525541079f0c8823a366ed49 100644 (file)
@@ -513,6 +513,27 @@ static const char *cgm_get_cgroup(void *hdata, const char *subsystem)
        return d->cgroup_path;
 }
 
+static int cgm_get_nrtasks(void *hdata)
+{
+       struct cgm_data *d = hdata;
+       int32_t *pids;
+       size_t pids_len;
+
+       if (!d || !d->cgroup_path)
+               return false;
+
+       if (cgmanager_get_tasks_sync(NULL, cgroup_manager, subsystems[0],
+                                    d->cgroup_path, &pids, &pids_len) != 0) {
+               NihError *nerr;
+               nerr = nih_error_get();
+               ERROR("call to cgmanager_get_tasks_sync failed: %s", nerr->message);
+               nih_free(nerr);
+               return -1;
+       }
+       nih_free(pids);
+       return pids_len;
+}
+
 static int cgm_get(const char *filename, char *value, size_t len, const char *name, const char *lxcpath)
 {
        char *result, *controller, *key, *cgroup;
@@ -862,6 +883,6 @@ static struct cgroup_ops cgmanager_ops = {
        .chown = cgm_chown,
        .attach = cgm_attach,
        .mount_cgroup = cgm_mount_cgroup,
-       .nrtasks = NULL,
+       .nrtasks = cgm_get_nrtasks,
 };
 #endif