From nobody Sun Feb 8 15:46:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1533822291946957.8603053891378; Thu, 9 Aug 2018 06:44:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A3253082265; Thu, 9 Aug 2018 13:44:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DA8832015ACA; Thu, 9 Aug 2018 13:44:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 81A4D3F67F; Thu, 9 Aug 2018 13:44:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79DiRjt015122 for ; Thu, 9 Aug 2018 09:44:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1A5452314D; Thu, 9 Aug 2018 13:44:27 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADF192314E for ; Thu, 9 Aug 2018 13:44:26 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 15:44:12 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 17/17] lxc: Use virCgroupGetMemoryStat 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 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 09 Aug 2018 13:44:50 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/lxc/lxc_cgroup.c | 65 +++++--------------------------------------- 1 file changed, 7 insertions(+), 58 deletions(-) diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index 8e937ec389..d93a19d684 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -220,64 +220,13 @@ static int virLXCCgroupGetMemTotal(virCgroupPtr cgrou= p, static int virLXCCgroupGetMemStat(virCgroupPtr cgroup, virLXCMeminfoPtr meminfo) { - int ret =3D 0; - FILE *statfd =3D NULL; - char *statFile =3D NULL; - char *line =3D NULL; - size_t n; - - ret =3D virCgroupPathOfController(cgroup, VIR_CGROUP_CONTROLLER_MEMORY, - "memory.stat", &statFile); - if (ret !=3D 0) { - virReportSystemError(-ret, "%s", - _("cannot get the path of MEMORY cgroup contr= oller")); - return ret; - } - - statfd =3D fopen(statFile, "r"); - if (statfd =3D=3D NULL) { - ret =3D -errno; - goto cleanup; - } - - while (getline(&line, &n, statfd) > 0) { - - char *value =3D strchr(line, ' '); - char *nl =3D value ? strchr(line, '\n') : NULL; - unsigned long long stat_value; - - if (!value) - continue; - - if (nl) - *nl =3D '\0'; - - *value =3D '\0'; - - if (virStrToLong_ull(value + 1, NULL, 10, &stat_value) < 0) { - ret =3D -EINVAL; - goto cleanup; - } - if (STREQ(line, "cache")) - meminfo->cached =3D stat_value >> 10; - else if (STREQ(line, "inactive_anon")) - meminfo->inactive_anon =3D stat_value >> 10; - else if (STREQ(line, "active_anon")) - meminfo->active_anon =3D stat_value >> 10; - else if (STREQ(line, "inactive_file")) - meminfo->inactive_file =3D stat_value >> 10; - else if (STREQ(line, "active_file")) - meminfo->active_file =3D stat_value >> 10; - else if (STREQ(line, "unevictable")) - meminfo->unevictable =3D stat_value >> 10; - } - ret =3D 0; - - cleanup: - VIR_FREE(line); - VIR_FREE(statFile); - VIR_FORCE_FCLOSE(statfd); - return ret; + return virCgroupGetMemoryStat(cgroup, + &meminfo->cached, + &meminfo->inactive_anon, + &meminfo->active_anon, + &meminfo->inactive_file, + &meminfo->active_file, + &meminfo->unevictable); } =20 =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list