[libvirt] [PATCH 2/3] cgroup: Move [qemu|lxc]GetCpuBWStatus to vicgroup.c and refactor it
Eric Blake
eblake at redhat.com
Fri Sep 13 15:53:14 UTC 2013
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130913/be403764/attachment-0001.sig>
More information about the libvir-list
mailing list