[libvirt] [PATCH 02/17] Introduce the function virCgroupMoveTask
Eric Blake
eblake at redhat.com
Mon Aug 6 21:09:51 UTC 2012
On 08/03/2012 12:36 AM, Hu Tao wrote:
> From: Wen Congyang <wency at cn.fujitsu.com>
>
> Introduce a new API to move tasks of one controller from a cgroup to another cgroup
>
> Signed-off-by: Wen Congyang <wency at cn.fujitsu.com>
> Signed-off-by: Tang Chen <tangchen at cn.fujitsu.com>
> Signed-off-by: Hu Tao <hutao at 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 eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120806/db727896/attachment-0001.sig>
More information about the libvir-list
mailing list