[libvirt] [PATCH] Fix build w/o cgroups

Eric Blake eblake at redhat.com
Thu Aug 1 20:40:14 UTC 2013

On 07/31/2013 11:27 PM, Roman Bogorodskiy wrote:
> Build without cgroups support started to fail again recently. Do the
> following to fix it:
>  - Add missing 'partition' arg that was added to the
>    virCgroupValidateMachineGroup() but forgotten for the stub
>    of the same function
>  - Add stubs for virCgroupMakeGroup() and virCgroupNew()
> ---
>  src/util/vircgroup.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)

Fails 'make syntax-check':

src/util/vircgroup.c:1001:                              unsigned int
maint.mk: flags should be checked with virCheckFlags

Don't know whether it makes more sense to add virCheckFlags(0, -1) or
rename the parameter.

> +#else
> +static int virCgroupMakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
> +                              virCgroupPtr group ATTRIBUTE_UNUSED,
> +                              bool create ATTRIBUTE_UNUSED,
> +                              unsigned int flags ATTRIBUTE_UNUSED)
> +{
> +    return -1;

Returning failure without setting an error message is awkward.

On 07/31/2013 11:34 PM, Roman Bogorodskiy wrote:
> One more comment on that. It's probably the time to think how to
> refactor this code, because it's becoming very hard to navigate through
> preprocessor macros' mess...

Indeed; part of the confusion is figuring out which static functions are
compiled under which conditions.  And since cgroups are really a
Linux-only concept, maybe it's easier to just have one giant #if/else
switch up front, rather than different conditionals for all the
intermediate functions:

#if defined(__linux__) && HAVE_MNTENT_H && defined(HAVE_GETMNTENT_R) \
 && defined(_DIRENT_HAVE_D_TYPE) && defined(major) && defined(minor)

real implementation of everything


placeholder implementation of all functions in the header


Looking forward to v2.

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/20130801/074dc5f1/attachment-0001.sig>

More information about the libvir-list mailing list