cgroup: Skip unified hier controllers (v2)

Submitted by Pavel Emelianov on June 29, 2017, 10:24 a.m.

Details

Message ID f24e439b-c86c-a096-f934-7b6058e9959b@virtuozzo.com
State Accepted
Series "cgroup: Skip unified hier controllers"
Headers show

Commit Message

Pavel Emelianov June 29, 2017, 10:24 a.m.
The unified hierarchy controller doesn't have any name, so criu hangs
while parsing this sort of strings.

Let's skip those for now, until we implement cgroup2 support.

https://github.com/xemul/criu/issues/252

v2: Code comments

Reported-and-tested-by: Adrian Reber <adrian@lisas.de>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/proc_parse.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index b8881d2..4609633 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -2335,8 +2335,19 @@  int parse_cgroup_file(FILE *f, struct list_head *retl, unsigned int *n)
 		 * 2:name=systemd:/user.slice/user-1000.slice/session-1.scope
 		 */
 		name = strchr(buf, ':');
-		if (name)
+		if (name) {
 			path = strchr(++name, ':');
+			if (*name == ':') {
+				/*
+				 * It's unified hierarchy. On kernels with legacy
+				 * tree this item is added automatically, so we
+				 * can just skip one. For those with full unified
+				 * support is on ... we need to write new code.
+				 */
+				xfree(ncc);
+				continue;
+			}
+		}
 		if (!name || !path) {
 			pr_err("Failed parsing cgroup %s\n", buf);
 			xfree(ncc);
@@ -2500,6 +2511,13 @@  int collect_controllers(struct list_head *cgroups, unsigned int *n_cgroups)
 		}
 		controllers++;
 
+		if (*controllers == ':')
+			/*
+			 * Unified hier. See comment in parse_cgroup_file
+			 * for more details.
+			 */
+			continue;
+
 		off = strchr(controllers, ':');
 		if (!off) {
 			pr_err("Unable to parse \"%s\"\n", buf);

Comments

Andrey Vagin July 7, 2017, 11:03 p.m.
Applied, thanks
On Thu, Jun 29, 2017 at 01:24:55PM +0300, Pavel Emelyanov wrote:
> The unified hierarchy controller doesn't have any name, so criu hangs
> while parsing this sort of strings.
> 
> Let's skip those for now, until we implement cgroup2 support.
> 
> https://github.com/xemul/criu/issues/252
> 
> v2: Code comments
> 
> Reported-and-tested-by: Adrian Reber <adrian@lisas.de>
> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
> ---
>  criu/proc_parse.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/criu/proc_parse.c b/criu/proc_parse.c
> index b8881d2..4609633 100644
> --- a/criu/proc_parse.c
> +++ b/criu/proc_parse.c
> @@ -2335,8 +2335,19 @@ int parse_cgroup_file(FILE *f, struct list_head *retl, unsigned int *n)
>  		 * 2:name=systemd:/user.slice/user-1000.slice/session-1.scope
>  		 */
>  		name = strchr(buf, ':');
> -		if (name)
> +		if (name) {
>  			path = strchr(++name, ':');
> +			if (*name == ':') {
> +				/*
> +				 * It's unified hierarchy. On kernels with legacy
> +				 * tree this item is added automatically, so we
> +				 * can just skip one. For those with full unified
> +				 * support is on ... we need to write new code.
> +				 */
> +				xfree(ncc);
> +				continue;
> +			}
> +		}
>  		if (!name || !path) {
>  			pr_err("Failed parsing cgroup %s\n", buf);
>  			xfree(ncc);
> @@ -2500,6 +2511,13 @@ int collect_controllers(struct list_head *cgroups, unsigned int *n_cgroups)
>  		}
>  		controllers++;
>  
> +		if (*controllers == ':')
> +			/*
> +			 * Unified hier. See comment in parse_cgroup_file
> +			 * for more details.
> +			 */
> +			continue;
> +
>  		off = strchr(controllers, ':');
>  		if (!off) {
>  			pr_err("Unable to parse \"%s\"\n", buf);
> -- 
> 2.1.4
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu