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

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(+) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index cfb4b3f..4cc7687 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -174,6 +174,7 @@ static bool virCgroupValidateMachineGroup(virCgroupPtr group ATTRIBUTE_UNUSED, const char *name ATTRIBUTE_UNUSED, const char *drivername ATTRIBUTE_UNUSED, + const char *partition ATTRIBUTE_UNUSED, bool stripEmulatorSuffix ATTRIBUTE_UNUSED) { return true; @@ -993,6 +994,23 @@ error: return -1; } +#else +static int virCgroupMakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED, + virCgroupPtr group ATTRIBUTE_UNUSED, + bool create ATTRIBUTE_UNUSED, + unsigned int flags ATTRIBUTE_UNUSED) +{ + return -1; +} + +static int virCgroupNew(pid_t pid ATTRIBUTE_UNUSED, + const char *path ATTRIBUTE_UNUSED, + virCgroupPtr parent ATTRIBUTE_UNUSED, + int controllers ATTRIBUTE_UNUSED, + virCgroupPtr *group ATTRIBUTE_UNUSED) +{ + return -1; +} #endif #if defined _DIRENT_HAVE_D_TYPE -- 1.7.11.5

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... 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(+)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index cfb4b3f..4cc7687 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -174,6 +174,7 @@ static bool virCgroupValidateMachineGroup(virCgroupPtr group ATTRIBUTE_UNUSED, const char *name ATTRIBUTE_UNUSED, const char *drivername ATTRIBUTE_UNUSED, + const char *partition ATTRIBUTE_UNUSED, bool stripEmulatorSuffix ATTRIBUTE_UNUSED) { return true; @@ -993,6 +994,23 @@ error:
return -1; } +#else +static int virCgroupMakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED, + virCgroupPtr group ATTRIBUTE_UNUSED, + bool create ATTRIBUTE_UNUSED, + unsigned int flags ATTRIBUTE_UNUSED) +{ + return -1; +} + +static int virCgroupNew(pid_t pid ATTRIBUTE_UNUSED, + const char *path ATTRIBUTE_UNUSED, + virCgroupPtr parent ATTRIBUTE_UNUSED, + int controllers ATTRIBUTE_UNUSED, + virCgroupPtr *group ATTRIBUTE_UNUSED) +{ + return -1; +} #endif
#if defined _DIRENT_HAVE_D_TYPE -- 1.7.11.5
Roman Bogorodskiy

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': flags_usage src/util/vircgroup.c:1001: unsigned int flags ATTRIBUTE_UNUSED) 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 #else placeholder implementation of all functions in the header #endif Looking forward to v2. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Eric Blake wrote:
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':
flags_usage src/util/vircgroup.c:1001: unsigned int flags ATTRIBUTE_UNUSED) 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
#else
placeholder implementation of all functions in the header
#endif
Looking forward to v2.
Hi, I've just published a patch with macros refactoring. As it's a different thing I decided to go with a new patch instead of 'v2'. Roman Bogorodskiy
participants (2)
-
Eric Blake
-
Roman Bogorodskiy