[libvirt] [PATCH 4/9] vircgroup: introduce virCgroupTaskFlags

Fabiano Fidêncio fidencio at redhat.com
Wed Sep 19 11:36:40 UTC 2018


On Tue, Sep 18, 2018 at 2:17 PM, Pavel Hrdina <phrdina at redhat.com> wrote:

> Use flags in virCgroupAddTaskInternal instead of boolean parameter.
> Following patch will ad new flag to indicate thread instead of process.
>

typo: ad -> add


>
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
>
---
>  src/util/vircgroup.c | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
> index cf510fb019..1d361762c5 100644
> --- a/src/util/vircgroup.c
> +++ b/src/util/vircgroup.c
> @@ -1156,8 +1156,16 @@ virCgroupNew(pid_t pid,
>  }
>
>
> +typedef enum {
> +    VIR_CGROUP_TASK_PROCESS = 0,
> +    VIR_CGROUP_TASK_SYSTEMD = 1 << 0,
>

Although not strictly needed, would be nice to have a comment describing
what the flags mean.


> +} virCgroupTaskFlags;
> +
> +
>  static int
> -virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd)
> +virCgroupAddTaskInternal(virCgroupPtr group,
> +                         pid_t pid,
> +                         unsigned int flags)
>  {
>      int ret = -1;
>      size_t i;
> @@ -1170,7 +1178,8 @@ virCgroupAddTaskInternal(virCgroupPtr group, pid_t
> pid, bool withSystemd)
>          /* We must never add tasks in systemd's hierarchy
>           * unless we're intentionally trying to move a
>           * task into a systemd machine scope */
> -        if (i == VIR_CGROUP_CONTROLLER_SYSTEMD && !withSystemd)
> +        if (i == VIR_CGROUP_CONTROLLER_SYSTEMD &&
> +            !(flags & VIR_CGROUP_TASK_SYSTEMD))
>              continue;
>
>          if (virCgroupSetValueI64(group, i, "tasks", pid) < 0)
> @@ -1196,7 +1205,7 @@ virCgroupAddTaskInternal(virCgroupPtr group, pid_t
> pid, bool withSystemd)
>  int
>  virCgroupAddProcess(virCgroupPtr group, pid_t pid)
>  {
> -    return virCgroupAddTaskInternal(group, pid, false);
> +    return virCgroupAddTaskInternal(group, pid, VIR_CGROUP_TASK_PROCESS);
>  }
>
>  /**
> @@ -1213,7 +1222,9 @@ virCgroupAddProcess(virCgroupPtr group, pid_t pid)
>  int
>  virCgroupAddMachineProcess(virCgroupPtr group, pid_t pid)
>  {
> -    return virCgroupAddTaskInternal(group, pid, true);
> +    return virCgroupAddTaskInternal(group, pid,
> +                                    VIR_CGROUP_TASK_PROCESS |
> +                                    VIR_CGROUP_TASK_SYSTEMD);
>  }
>
>
> --
> 2.17.1
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>

Reviewed-by: Fabiano Fidêncio <fidencio at redhat.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180919/082196f3/attachment-0001.htm>


More information about the libvir-list mailing list