]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc: fuse: Fill in MemAvailable for /proc/meminfo
authorCole Robinson <crobinso@redhat.com>
Thu, 21 Jan 2016 18:18:04 +0000 (13:18 -0500)
committerCole Robinson <crobinso@redhat.com>
Fri, 22 Jan 2016 13:32:00 +0000 (08:32 -0500)
'free' on Fedora 23 will use MemAvailable to calculate its 'available'
field, but we are passing through the host's value. Set it to match
MemFree, which is what 'free' will do for older linux that don't have
MemAvailable

https://bugzilla.redhat.com/show_bug.cgi?id=1300781

src/lxc/lxc_fuse.c

index ffa688936550c3f7edb13f26abba325ac84088ee..0a1c7dca15e01302e8fb4d7e9e2e128821290f21 100644 (file)
@@ -174,6 +174,14 @@ static int lxcProcReadMeminfo(char *hostpath, virDomainDefPtr def,
                     virDomainDefGetMemoryActual(def))) {
             virBufferAsprintf(new_meminfo, "MemFree:        %8llu kB\n",
                               (meminfo.memtotal - meminfo.memusage));
+        } else if (STREQ(line, "MemAvailable") &&
+                   (virMemoryLimitIsSet(def->mem.hard_limit) ||
+                    virDomainDefGetMemoryActual(def))) {
+            /* MemAvailable is actually MemFree + SRReclaimable +
+               some other bits, but MemFree is the closest approximation
+               we have */
+            virBufferAsprintf(new_meminfo, "MemAvailable:   %8llu kB\n",
+                              (meminfo.memtotal - meminfo.memusage));
         } else if (STREQ(line, "Buffers")) {
             virBufferAsprintf(new_meminfo, "Buffers:        %8d kB\n", 0);
         } else if (STREQ(line, "Cached")) {