From: Serge Hallyn Date: Mon, 7 Mar 2016 19:24:41 +0000 (-0800) Subject: cgfsng: print debuginfo if LXC_DEBUG_CGFSNG env variable is set X-Git-Tag: lxc-2.0.0.rc6~1^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41c33dbec5d27182b80c59aa3ed0fbcc1df7216b;p=thirdparty%2Flxc.git cgfsng: print debuginfo if LXC_DEBUG_CGFSNG env variable is set Note this is printing to stdout because it runs before logging is setup. Signed-off-by: Serge Hallyn --- diff --git a/src/lxc/cgfsng.c b/src/lxc/cgfsng.c index c3ab39679..f5e349e62 100644 --- a/src/lxc/cgfsng.c +++ b/src/lxc/cgfsng.c @@ -52,8 +52,6 @@ lxc_log_define(lxc_cgfsng, lxc); static struct cgroup_ops cgfsng_ops; -//#define EXTRADEBUG 1 - /* * A descriptor for a mounted hierarchy * @controllers: either NULL, or a null-terminated list of all @@ -609,10 +607,13 @@ static void trim(char *s) s[--len] = '\0'; } -#if EXTRADEBUG static void print_init_debuginfo(struct cgfsng_handler_data *d) { int i; + + if (!getenv("LXC_DEBUG_CGFSNG")) + return; + printf("Cgroup information:\n"); printf(" container name: %s\n", d->name); printf(" lxc.cgroup.use: %s\n", d->cgroup_use ? d->cgroup_use : "(none)"); @@ -633,9 +634,20 @@ static void print_init_debuginfo(struct cgfsng_handler_data *d) printf(" %d: %s\n", j, h->controllers[j]); } } -#else -#define print_init_debuginfo(d) -#endif + +static void print_basecg_debuginfo(char *basecginfo, char **klist, char **nlist) +{ + int k; + if (!getenv("LXC_DEBUG_CGFSNG")) + return; + + printf("basecginfo is %s\n", basecginfo); + + for (k = 0; klist[k]; k++) + printf("kernel subsystem %d: %s\n", k, klist[k]); + for (k = 0; nlist[k]; k++) + printf("named subsystem %d: %s\n", k, nlist[k]); +} /* * At startup, parse_hierarchies finds all the info we need about @@ -665,14 +677,8 @@ static bool parse_hierarchies(struct cgfsng_handler_data *d) } get_existing_subsystems(&klist, &nlist); -#if EXTRADEBUG - printf("basecginfo is %s\n", basecginfo); - int k; - for (k = 0; klist[k]; k++) - printf("kernel subsystem %d: %s\n", k, klist[k]); - for (k = 0; nlist[k]; k++) - printf("named subsystem %d: %s\n", k, nlist[k]); -#endif + + print_basecg_debuginfo(basecginfo, klist, nlist); /* we support simple cgroup mounts and lxcfs mounts */ while (getline(&line, &len, f) != -1) {