[lxc-devel] [PATCH] detect whether cgmanager_list_controllers is available

Stéphane Graber stgraber at ubuntu.com
Wed Jun 3 14:34:34 UTC 2015


On Wed, Jun 03, 2015 at 05:03:39AM +0000, Serge Hallyn wrote:
> and don't use it if not. This fixes failure to build with older
> cgmanager.
> 
> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

> ---
>  configure.ac        | 11 +++++++++++
>  src/lxc/cgmanager.c |  7 +++++++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/configure.ac b/configure.ac
> index f5d6438..5fa9b4e 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -284,6 +284,17 @@ else
>  	AC_MSG_RESULT([no])
>  fi
>  
> +AC_MSG_CHECKING(for cgmanager_list_controllers)
> +save_LIBS=$LIBS
> +AC_SEARCH_LIBS([cgmanager_list_controllers_sync], [cgmanager], [have_list_controllers=yes], [have_list_controllers=no], [-lnih -lnih-dbus -ldbus-1])
> +LIBS=$save_LIBS
> +if test "x$have_list_controllers" = "xyes"; then
> +	AC_DEFINE([HAVE_CGMANAGER_LIST_CONTROLLERS], 1, [Have cgmanager_list_controllers])
> +	AC_MSG_RESULT([yes])
> +else
> +	AC_MSG_RESULT([no])
> +fi
> +
>  # Check for static libcap, make sure the function checked for differs from the
>  # the one checked below so the cache doesn't give a wrong answer
>  OLD_CFLAGS="$CFLAGS"
> diff --git a/src/lxc/cgmanager.c b/src/lxc/cgmanager.c
> index 6b6c2d8..6df530c 100644
> --- a/src/lxc/cgmanager.c
> +++ b/src/lxc/cgmanager.c
> @@ -818,6 +818,7 @@ out:
>  	return pids_len;
>  }
>  
> +#if HAVE_CGMANAGER_LIST_CONTROLLERS
>  static bool lxc_list_controllers(char ***list)
>  {
>  	if (!cgm_dbus_connect()) {
> @@ -836,6 +837,12 @@ static bool lxc_list_controllers(char ***list)
>  	cgm_dbus_disconnect();
>  	return true;
>  }
> +#else
> +static bool lxc_list_controllers(char ***list)
> +{
> +	return false;
> +}
> +#endif
>  
>  static inline void free_abs_cgroup(char *cgroup)
>  {
> -- 
> 2.1.4
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20150603/e691a982/attachment.sig>


More information about the lxc-devel mailing list