[Pkg-libvirt-maintainers] Bug#913023: libvirt0: Parsing of memory.stat is incorrect

Peter.Chubb at data61.csiro.au Peter.Chubb at data61.csiro.au
Tue Nov 6 04:33:33 GMT 2018


Package: libvirt0
Version: 4.7.0-1+b1
Severity: normal

Dear Maintainer,
 The parsing of memory.stat is incorrect in src/util/vircgroup.c
 It spams the logs with
error : virCgroupGetMemoryStat:2490 : internal error: Cannot parse 'memory.stat' cgroup file.
whenever anyone does `ps' inside a container.

Here is a patch to fix it.  There may be a better way.
The problem is that 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.


 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;

-- System Information:
Debian Release: buster/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 4.18.0-1-amd64 (SMP w/28 CPU cores)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8), LANGUAGE=en_AU:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libvirt0 depends on:
ii  libacl1             2.2.52-3+b1
ii  libapparmor1        2.13.1-3+b1
ii  libaudit1           1:2.8.4-2
ii  libavahi-client3    0.7-4+b1
ii  libavahi-common3    0.7-4+b1
ii  libc6               2.27-8
ii  libcap-ng0          0.7.9-1
ii  libcurl3-gnutls     7.62.0-1
ii  libdbus-1-3         1.12.10-1
ii  libdevmapper1.02.1  2:1.02.145-4.1
ii  libgcc1             1:8.2.0-9
ii  libgnutls30         3.5.19-1+b1
ii  libnl-3-200         3.4.0-1
ii  libnl-route-3-200   3.4.0-1
ii  libnuma1            2.0.12-1
ii  libsasl2-2          2.1.27~rc8-1
ii  libselinux1         2.8-1+b1
ii  libssh2-1           1.8.0-2
ii  libxml2             2.9.4+dfsg1-7+b1
ii  libyajl2            2.1.0-3

Versions of packages libvirt0 recommends:
ii  lvm2  2.02.176-4.1

libvirt0 suggests no packages.

-- no debconf information

-- 
Dr Peter Chubb         Tel: +61 2 9490 5852      http://ts.data61.csiro.au/
Trustworthy Systems Group                     Data61, CSIRO (formerly NICTA)


More information about the Pkg-libvirt-maintainers mailing list