[libvirt] [PATCH 07/53] vircgroup: introduce virCgroupV2DetectPlacement

Michal Privoznik mprivozn at redhat.com
Thu Oct 4 11:18:20 UTC 2018


On 10/02/2018 10:43 AM, Pavel Hrdina wrote:
> If the placement was copied from parent or set to absolute path
> there is nothing to do, otherwise set the placement based on
> process placement from /proc/self/cgroup or /proc/{pid}/cgroup.
> 
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> ---
>  src/util/vircgroupv2.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
> index eaf07397d5..ed94d5da17 100644
> --- a/src/util/vircgroupv2.c
> +++ b/src/util/vircgroupv2.c
> @@ -182,6 +182,31 @@ virCgroupV2DetectMounts(virCgroupPtr group,
>  }
>  
>  
> +static int
> +virCgroupV2DetectPlacement(virCgroupPtr group,
> +                           const char *path,
> +                           const char *controllers ATTRIBUTE_UNUSED,
> +                           const char *selfpath)
> +{
> +    if (group->unified.placement)
> +        return 0;
> +
> +    /*
> +     * selfpath == "/" + path="" -> "/"
> +     * selfpath == "/libvirt.service" + path == "" -> "/libvirt.service"
> +     * selfpath == "/libvirt.service" + path == "foo" -> "/libvirt.service/foo"
> +     */
> +    if (virAsprintf(&group->unified.placement,
> +                    "%s%s%s", selfpath,
> +                    (STREQ(selfpath, "/") ||
> +                     STREQ(path, "") ? "" : "/"),
> +                    path) < 0)
> +        return -1;

Same comment here as in 05/53.

> +
> +    return 0;
> +}
> +
> +
>  virCgroupBackend virCgroupV2Backend = {
>      .type = VIR_CGROUP_BACKEND_TYPE_V2,
>  
> @@ -190,6 +215,7 @@ virCgroupBackend virCgroupV2Backend = {
>      .copyMounts = virCgroupV2CopyMounts,
>      .copyPlacement = virCgroupV2CopyPlacement,
>      .detectMounts = virCgroupV2DetectMounts,
> +    .detectPlacement = virCgroupV2DetectPlacement,
>  };
>  
>  
> 

ACK

Michal




More information about the libvir-list mailing list