[lxc-devel] [PATCH] cgmanager: slow down there (don't always grab abs cgroup path)

Stéphane Graber stgraber at ubuntu.com
Tue May 20 20:49:21 UTC 2014


On Tue, May 20, 2014 at 11:47:17AM -0500, Serge Hallyn wrote:
> When I converted attach and enter to using move_pid_abs, these needed
> to use the new get_pid_cgroup_abs method to get an absolute path.  But
> for some inexplicable reason I also converted the functions which get
> and set cgroup properties to use the absolute paths.  These are simply
> not compatible with the cgmanager set_value and get_value methods.
> This breaks for instance lxc-test-cgpath.
> 
> So undo that.  With this patch lxc-test-cgpath, lxc-test-autotest,
> and lxc-test-concurrent once again pass in a nested container.
> 
> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>

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

> ---
>  src/lxc/cgmanager.c | 32 ++++++++++++++++----------------
>  1 file changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/src/lxc/cgmanager.c b/src/lxc/cgmanager.c
> index 9b06d31..3a5525a 100644
> --- a/src/lxc/cgmanager.c
> +++ b/src/lxc/cgmanager.c
> @@ -714,14 +714,13 @@ static int cgm_get(const char *filename, char *value, size_t len, const char *na
>  		return -1;
>  	*key = '\0';
>  
> -	if (!cgm_dbus_connect()) {
> -		ERROR("Error connecting to cgroup manager");
> +	/* use the command interface to look for the cgroup */
> +	cgroup = lxc_cmd_get_cgroup_path(name, lxcpath, controller);
> +	if (!cgroup)
>  		return -1;
> -	}
>  
> -	cgroup = try_get_abs_cgroup(name, lxcpath, controller);
> -	if (!cgroup) {
> -		cgm_dbus_disconnect();
> +	if (!cgm_dbus_connect()) {
> +		ERROR("Error connecting to cgroup manager");
>  		return -1;
>  	}
>  
> @@ -734,12 +733,12 @@ static int cgm_get(const char *filename, char *value, size_t len, const char *na
>  		NihError *nerr;
>  		nerr = nih_error_get();
>  		nih_free(nerr);
> -		free_abs_cgroup(cgroup);
> +		free(cgroup);
>  		cgm_dbus_disconnect();
>  		return -1;
>  	}
>  	cgm_dbus_disconnect();
> -	free_abs_cgroup(cgroup);
> +	free(cgroup);
>  	newlen = strlen(result);
>  	if (!len || !value) {
>  		// user queries the size
> @@ -790,21 +789,22 @@ static int cgm_set(const char *filename, const char *value, const char *name, co
>  		return -1;
>  	*key = '\0';
>  
> -	if (!cgm_dbus_connect()) {
> -		ERROR("Error connecting to cgroup manager");
> -		free(cgroup);
> -		return false;
> -	}
> -	cgroup = try_get_abs_cgroup(name, lxcpath, controller);
> +	/* use the command interface to look for the cgroup */
> +	cgroup = lxc_cmd_get_cgroup_path(name, lxcpath, controller);
>  	if (!cgroup) {
>  		ERROR("Failed to get cgroup for controller %s for %s:%s",
>  			controller, lxcpath, name);
> -		cgm_dbus_disconnect();
>  		return -1;
>  	}
> +
> +	if (!cgm_dbus_connect()) {
> +		ERROR("Error connecting to cgroup manager");
> +		free(cgroup);
> +		return false;
> +	}
>  	ret = cgm_do_set(controller, filename, cgroup, value);
>  	cgm_dbus_disconnect();
> -	free_abs_cgroup(cgroup);
> +	free(cgroup);
>  	return ret;
>  }
>  
> -- 
> 1.9.1
> 
> _______________________________________________
> 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/20140520/b3f4dcb0/attachment.sig>


More information about the lxc-devel mailing list