On 08/03/2012 12:36 AM, Hu Tao wrote:
> From: Wen Congyang <we...@cn.fujitsu.com>
> 
> Introduce a new API to move tasks of one controller from a cgroup to another 
> cgroup
> 
> Signed-off-by: Wen Congyang <we...@cn.fujitsu.com>
> Signed-off-by: Tang Chen <tangc...@cn.fujitsu.com>
> Signed-off-by: Hu Tao <hu...@cn.fujitsu.com>
> ---

> +static int virCgroupAddTaskStrController(virCgroupPtr group,
> +                                        const char *pidstr,
> +                                        int controller)
> +{
> +    char *str = NULL, *cur = NULL, *next = NULL;
> +    unsigned long long p = 0;
> +    int rc = 0;
> +
> +    if (virAsprintf(&str, "%s", pidstr) < 0)
> +        return -1;
> +
> +    cur = str;
> +    while ((next = strchr(cur, '\n')) != NULL) {
> +        *next = '\0';
> +        rc = virStrToLong_ull(cur, NULL, 10, &p);
> +        if (rc != 0)
> +            goto cleanup;
> +        cur = next + 1;
> +
> +        rc = virCgroupAddTaskController(group, p, controller);
> +        if (rc != 0)
> +            goto cleanup;
> +    }
> +    if (cur != '\0') {
> +        rc = virStrToLong_ull(cur, NULL, 10, &p);
> +        if (rc != 0)
> +            goto cleanup;
> +        rc = virCgroupAddTaskController(group, p, controller);
> +        if (rc != 0)
> +            goto cleanup;
> +    }

Can this last if statement be folded into the while loop for less code
duplication?  If the series passes review now, then I'm probably not
worried enough to change it and would probably push as is; but if we
need a v2, then it's worth improving.

Another patch that looks decent in isolation.

-- 
Eric Blake   ebl...@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to