[lxc-devel] [PATCH] implement cgmanager nrtasks
Serge Hallyn
serge.hallyn at ubuntu.com
Thu Feb 6 20:47:34 UTC 2014
Quoting Dwight Engen (dwight.engen at oracle.com):
> 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 at oracle.com>
Looks great, thanks.
Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
(Stéphane is tagging beta right now so I'll let him push it when
convenient)
> ---
> src/lxc/cgmanager.c | 23 ++++++++++++++++++++++-
> 1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/src/lxc/cgmanager.c b/src/lxc/cgmanager.c
> index 6798b6b..37f4eb3 100644
> --- a/src/lxc/cgmanager.c
> +++ b/src/lxc/cgmanager.c
> @@ -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
> --
> 1.8.5.3
>
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel
More information about the lxc-devel
mailing list