On 08/03/2012 12:36 AM, Hu Tao wrote:
> From: Wen Congyang <[email protected]>
> 
> Introduce a new API to move tasks of one controller from a cgroup to another 
> cgroup
> 
> Signed-off-by: Wen Congyang <[email protected]>
> Signed-off-by: Tang Chen <[email protected]>
> Signed-off-by: Hu Tao <[email protected]>
> ---

> +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   [email protected]    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to