[lxc-devel] [PATCH 1/1] cgmanager: detect whether cgmanager supports name= subsystems

Stéphane Graber stgraber at ubuntu.com
Thu May 8 17:55:06 UTC 2014


On Thu, May 08, 2014 at 12:23:53PM -0500, Serge Hallyn wrote:
> On older cgmanager the support was broken.  So rather than
> fail container starts altogether, just keep the old lxc behavior
> in this case by not using name= subsystems.
> 
> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>

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

> ---
>  src/lxc/cgmanager.c | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lxc/cgmanager.c b/src/lxc/cgmanager.c
> index 1c9ac55..9b06d31 100644
> --- a/src/lxc/cgmanager.c
> +++ b/src/lxc/cgmanager.c
> @@ -51,6 +51,9 @@
>  #include "start.h"
>  #include "state.h"
>  
> +#define CGM_SUPPORTS_GET_ABS 3
> +#define CGM_SUPPORTS_NAMED 4
> +
>  #ifdef HAVE_CGMANAGER
>  lxc_log_define(lxc_cgmanager, lxc);
>  
> @@ -113,6 +116,7 @@ static struct cgroup_ops cgmanager_ops;
>  static int nr_subsystems;
>  static char **subsystems;
>  static bool dbus_threads_initialized = false;
> +static void cull_user_controllers(void);
>  
>  static void cgm_dbus_disconnect(void)
>  {
> @@ -172,6 +176,8 @@ static bool cgm_dbus_connect(void)
>  		cgm_dbus_disconnect();
>  		return false;
>  	}
> +	if (api_version < CGM_SUPPORTS_NAMED)
> +		cull_user_controllers();
>  	return true;
>  }
>  
> @@ -617,7 +623,7 @@ static const char *cgm_get_cgroup(void *hdata, const char *subsystem)
>  
>  #if HAVE_CGMANAGER_GET_PID_CGROUP_ABS_SYNC
>  static inline bool abs_cgroup_supported(void) {
> -	return api_version >= 3;
> +	return api_version >= CGM_SUPPORTS_GET_ABS;
>  }
>  #else
>  static inline bool abs_cgroup_supported(void) {
> @@ -813,6 +819,19 @@ static void free_subsystems(void)
>  	nr_subsystems = 0;
>  }
>  
> +static void cull_user_controllers(void)
> +{
> +	int i, j;
> +
> +	for (i = 0;  i < nr_subsystems; i++) {
> +		if (strncmp(subsystems[i], "name=", 5) != 0)
> +			continue;
> +		for (j = i;  j < nr_subsystems-1; j++)
> +			subsystems[j] = subsystems[j+1];
> +		nr_subsystems--;
> +	}
> +}
> +
>  static bool collect_subsytems(void)
>  {
>  	char *line = NULL;
> -- 
> 1.8.3.2
> 
> _______________________________________________
> 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/20140508/80b72b84/attachment.sig>


More information about the lxc-devel mailing list