From patchwork Thu Jan 21 18:42:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 60101 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp178472lbb; Thu, 21 Jan 2016 10:45:44 -0800 (PST) X-Received: by 10.28.23.5 with SMTP id 5mr12355650wmx.82.1453401943882; Thu, 21 Jan 2016 10:45:43 -0800 (PST) Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com. [209.132.183.39]) by mx.google.com with ESMTPS id js4si3389209wjc.164.2016.01.21.10.45.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2016 10:45:43 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0LIh9lL015633; Thu, 21 Jan 2016 13:43:10 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u0LIh6Yh013976 for ; Thu, 21 Jan 2016 13:43:06 -0500 Received: from colepc.redhat.com (ovpn-113-198.phx2.redhat.com [10.3.113.198]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0LIh4Yi032379; Thu, 21 Jan 2016 13:43:06 -0500 From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 21 Jan 2016 13:42:59 -0500 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/4] lxc: fuse: Fill in MemAvailable for /proc/meminfo X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com '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 | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.5.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c index ffa6889..0a1c7dc 100644 --- a/src/lxc/lxc_fuse.c +++ b/src/lxc/lxc_fuse.c @@ -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")) {