Parsing of memory.stat in libvirt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux