Hi Folks,
libvirt currently spams the logs with
error : virCgroupGetMemoryStat:2490 : internal error: Cannot parse 'memory.stat'
cgroup file
whenever someone does ps in a container.
This is because the parser for memory/stat is incorrect: the `line'
variable is never updated, so each time through the loop, the same
start-of-line is compared for the token; and as all spaces are
eventually replaced with NUL the error exit is taken instead of
ending the loop properly.
Here is a strawman patch to fix the problem. Please note, I'm not
subscribed to this list; I reported the bug as
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=913023 and was asked
to send the patch upstream.
src/util/vircgroup.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
--- libvirt.orig/src/util/vircgroup.c
+++ libvirt/src/util/vircgroup.c
@@ -2477,7 +2477,7 @@ virCgroupGetMemoryStat(virCgroupPtr grou
line = stat;
- while (line) {
+ while (*line) {
char *newLine = strchr(line, '\n');
char *valueStr = strchr(line, ' ');
unsigned long long value;
@@ -2507,6 +2507,11 @@ virCgroupGetMemoryStat(virCgroupPtr grou
inactiveFileVal = value >> 10;
else if (STREQ(line, "unevictable"))
unevictableVal = value >> 10;
+
+ if (newLine)
+ line = newLine + 1;
+ else
+ break;
}
*cache = cacheVal;
--
Dr Peter Chubb Tel: +61 2 9490 5852
http://ts.data61.csiro.au/
Trustworthy Systems Group Data61 (formerly NICTA)