cgroupfs/cgfsng: tweak logging

parent be5c06ec
...@@ -204,7 +204,7 @@ static void must_append_controller(char **klist, char **nlist, char ***clist, ch ...@@ -204,7 +204,7 @@ static void must_append_controller(char **klist, char **nlist, char ***clist, ch
char *copy; char *copy;
if (string_in_list(klist, entry) && string_in_list(nlist, entry)) { if (string_in_list(klist, entry) && string_in_list(nlist, entry)) {
ERROR("Refusing to use ambiguous controller '%s'", entry); ERROR("Refusing to use ambiguous controller \"%s\"", entry);
ERROR("It is both a named and kernel subsystem"); ERROR("It is both a named and kernel subsystem");
return; return;
} }
...@@ -724,19 +724,21 @@ static bool all_controllers_found(void) ...@@ -724,19 +724,21 @@ static bool all_controllers_found(void)
struct hierarchy ** hlist = hierarchies; struct hierarchy ** hlist = hierarchies;
if (!controller_found(hlist, "freezer")) { if (!controller_found(hlist, "freezer")) {
ERROR("no freezer controller mountpoint found"); ERROR("No freezer controller mountpoint found");
return false; return false;
} }
if (!cgroup_use) if (!cgroup_use)
return true; return true;
for (p = strtok_r(cgroup_use, ",", &saveptr); p; for (p = strtok_r(cgroup_use, ",", &saveptr); p;
p = strtok_r(NULL, ",", &saveptr)) { p = strtok_r(NULL, ",", &saveptr)) {
if (!controller_found(hlist, p)) { if (!controller_found(hlist, p)) {
ERROR("no %s controller mountpoint found", p); ERROR("No %s controller mountpoint found", p);
return false; return false;
} }
} }
return true; return true;
} }
...@@ -778,14 +780,14 @@ static char **get_controllers(char **klist, char **nlist, char *line) ...@@ -778,14 +780,14 @@ static char **get_controllers(char **klist, char **nlist, char *line)
return NULL; return NULL;
/* note - if we change how mountinfo works, then our caller /* note - if we change how mountinfo works, then our caller
* will need to verify /sys/fs/cgroup/ in this field */ * will need to verify /sys/fs/cgroup/ in this field */
if (strncmp(p, "/sys/fs/cgroup/", 15) != 0) { if (strncmp(p, "/sys/fs/cgroup/", 15)) {
INFO("cgfsng: found hierarchy not under /sys/fs/cgroup: \"%s\"", p); INFO("Found hierarchy not under /sys/fs/cgroup: \"%s\"", p);
return NULL; return NULL;
} }
p += 15; p += 15;
p2 = strchr(p, ' '); p2 = strchr(p, ' ');
if (!p2) { if (!p2) {
ERROR("corrupt mountinfo"); ERROR("Corrupt mountinfo");
return NULL; return NULL;
} }
*p2 = '\0'; *p2 = '\0';
...@@ -800,10 +802,8 @@ static char **get_controllers(char **klist, char **nlist, char *line) ...@@ -800,10 +802,8 @@ static char **get_controllers(char **klist, char **nlist, char *line)
* mountpoints such as "/sys/fs/cgroup/cpu,cpuacct". * mountpoints such as "/sys/fs/cgroup/cpu,cpuacct".
*/ */
dup = strdup(p); dup = strdup(p);
if (!dup) { if (!dup)
SYSERROR("Failed to duplicate string");
return NULL; return NULL;
}
for (tok = strtok_r(dup, ",", &saveptr); tok; for (tok = strtok_r(dup, ",", &saveptr); tok;
tok = strtok_r(NULL, ",", &saveptr)) { tok = strtok_r(NULL, ",", &saveptr)) {
...@@ -1021,15 +1021,15 @@ static void lxc_cgfsng_print_hierarchies() ...@@ -1021,15 +1021,15 @@ static void lxc_cgfsng_print_hierarchies()
int i; int i;
if (!hierarchies) { if (!hierarchies) {
printf(" No hierarchies found."); printf(" No hierarchies found\n");
return; return;
} }
printf(" Hierarchies:\n"); printf(" Hierarchies:\n");
for (i = 0, it = hierarchies; it && *it; it++, i++) { for (i = 0, it = hierarchies; it && *it; it++, i++) {
char **cit; char **cit;
int j; int j;
printf(" %d: base_cgroup %s\n", i, (*it)->base_cgroup ? (*it)->base_cgroup : "(null)"); printf(" %d: base_cgroup: %s\n", i, (*it)->base_cgroup ? (*it)->base_cgroup : "(null)");
printf(" mountpoint %s\n", (*it)->mountpoint ? (*it)->mountpoint : "(null)"); printf(" mountpoint: %s\n", (*it)->mountpoint ? (*it)->mountpoint : "(null)");
printf(" controllers:\n"); printf(" controllers:\n");
for (j = 0, cit = (*it)->controllers; cit && *cit; cit++, j++) for (j = 0, cit = (*it)->controllers; cit && *cit; cit++, j++)
printf(" %d: %s\n", j, *cit); printf(" %d: %s\n", j, *cit);
...@@ -1079,7 +1079,7 @@ static bool parse_hierarchies(void) ...@@ -1079,7 +1079,7 @@ static bool parse_hierarchies(void)
return false; return false;
if ((f = fopen("/proc/self/mountinfo", "r")) == NULL) { if ((f = fopen("/proc/self/mountinfo", "r")) == NULL) {
SYSERROR("Failed opening /proc/self/mountinfo"); SYSERROR("Failed to open \"/proc/self/mountinfo\"");
return false; return false;
} }
...@@ -1109,14 +1109,14 @@ static bool parse_hierarchies(void) ...@@ -1109,14 +1109,14 @@ static bool parse_hierarchies(void)
mountpoint = get_mountpoint(line); mountpoint = get_mountpoint(line);
if (!mountpoint) { if (!mountpoint) {
ERROR("Error reading mountinfo: bad line '%s'", line); ERROR("Failed parsing mountpoint from \"%s\"", line);
free_string_list(controller_list); free_string_list(controller_list);
continue; continue;
} }
base_cgroup = get_current_cgroup(basecginfo, controller_list[0]); base_cgroup = get_current_cgroup(basecginfo, controller_list[0]);
if (!base_cgroup) { if (!base_cgroup) {
ERROR("Failed to find current cgroup for controller '%s'", controller_list[0]); ERROR("Failed to find current cgroup for controller \"%s\"", controller_list[0]);
free_string_list(controller_list); free_string_list(controller_list);
free(mountpoint); free(mountpoint);
continue; continue;
...@@ -1153,10 +1153,8 @@ static bool parse_hierarchies(void) ...@@ -1153,10 +1153,8 @@ static bool parse_hierarchies(void)
/* verify that all controllers in cgroup.use and all crucial /* verify that all controllers in cgroup.use and all crucial
* controllers are accounted for * controllers are accounted for
*/ */
if (!all_controllers_found()) { if (!all_controllers_found())
INFO("cgfsng: not all controllers were find, deferring to cgfs driver");
return false; return false;
}
return true; return true;
} }
...@@ -1167,7 +1165,7 @@ static bool collect_hierarchy_info(void) ...@@ -1167,7 +1165,7 @@ static bool collect_hierarchy_info(void)
errno = 0; errno = 0;
tmp = lxc_global_config_value("lxc.cgroup.use"); tmp = lxc_global_config_value("lxc.cgroup.use");
if (!cgroup_use && errno != 0) { /* lxc.cgroup.use can be NULL */ if (!cgroup_use && errno != 0) { /* lxc.cgroup.use can be NULL */
SYSERROR("cgfsng: error reading list of cgroups to use"); ERROR("Failed to retrieve list of cgroups to use");
return false; return false;
} }
cgroup_use = must_copy_string(tmp); cgroup_use = must_copy_string(tmp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment