[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 2/3] cgroup: Move [qemu|lxc]GetCpuBWStatus to vicgroup.c and refactor it



On 09/13/2013 08:19 AM, Peter Krempa wrote:

s/vicgroup/vircgroup/ in the subject

> The function existed in two identical instances in lxc and qemu. Move it
> to vircgroup.c and simplify it. Refactor the callers too.
> ---

> +++ b/src/util/vircgroup.c
> @@ -3647,3 +3647,32 @@ virCgroupIsolateMount(virCgroupPtr group ATTRIBUTE_UNUSED,
>  }
> 
>  #endif /* !VIR_CGROUP_SUPPORTED */
> +
> +/**
> + * virCgroupSupportsCpuBW():
> + * Check whether the host supports CFS bandwidth.
> + *
> + * Return true when CFS bandwidth is supported,
> + * false when CFS bandwidth is not supported.
> + */
> +bool
> +virCgroupSupportsCpuBW(virCgroupPtr cgroup)
> +{
> +    char *path = NULL;
> +    int ret = false;
> +
> +    if (!cgroup)
> +        return false;
> +
> +    if (virCgroupPathOfController(cgroup, VIR_CGROUP_CONTROLLER_CPU,
> +                                  "cpu.cfs_period_us", &path) < 0) {

When cgroups are not compiled in, this function call always results in
an error;

> +        virResetLastError();

that you will just ignore.  Rather than pollute the logs, it may be
nicer to put the REAL implementation inside the #if, then provide the
#else a version that just silently returns false without spamming the logs.

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

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]