From nobody Wed May 1 12:55:05 2024 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1517240287441612.7305732249208; Mon, 29 Jan 2018 07:38:07 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8DF65356F4; Mon, 29 Jan 2018 15:38:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 180FE605E2; Mon, 29 Jan 2018 15:38:05 +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 D31FF18033DE; Mon, 29 Jan 2018 15:38:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0TFc3RK001379 for ; Mon, 29 Jan 2018 10:38:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 50E8361F24; Mon, 29 Jan 2018 15:38:03 +0000 (UTC) Received: from caroline.localdomain (unknown [10.43.2.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2403F61F31 for ; Mon, 29 Jan 2018 15:38:00 +0000 (UTC) Received: from caroline.brq.redhat.com (caroline.usersys.redhat.com [127.0.0.1]) by caroline.localdomain (Postfix) with ESMTP id ED75D1200FE for ; Mon, 29 Jan 2018 16:37:58 +0100 (CET) From: Martin Kletzander To: libvir-list@redhat.com Date: Mon, 29 Jan 2018 16:37:57 +0100 Message-Id: <024a75c710d412d1a32e42782b69239f9c7c6d30.1517240003.git.mkletzan@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4.5/4 variant 2] util: Use stat() on files under /sys/fs/resctrl/info 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 29 Jan 2018 15:38:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We are skipping non-directories under /sys/fs/resctrl/info/ since those are= not interesting for us. However in tests it can sometimes happen that ent->d_t= ype is 0 instead of 4 (DT_DIR) for directories. I've seen it fail on two machines. Different machines, different systems, I cannot reproduce it even using the same setup. So one of the ways how to w= ork around this is call stat() on it. Signed-off-by: Martin Kletzander --- src/util/virresctrl.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 684cb22fd8a2..12dda76f9d33 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -409,11 +409,32 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl) } while ((rv =3D virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH "/info")) > 0= ) { + struct stat st; + char *path =3D NULL; + VIR_DEBUG("Parsing info type '%s'", ent->d_name); + if (virAsprintf(&path, SYSFS_RESCTRL_PATH "/info/%s", ent->d_name)= < 0) + continue; + + if (stat(path, &st) < 0) { + virReportSystemError(errno, _("Cannot stat '%s'"), path); + VIR_FREE(path); + continue; + } + VIR_FREE(path); + + /* + * So this doesn't work on some machines when we're mocking syscal= ls in tests + if (ent->d_type !=3D DT_DIR) continue; + But the following does, for some reason. + */ + if ((st.st_mode & S_IFMT) !=3D S_IFDIR) + continue; + if (ent->d_name[0] !=3D 'L') continue; -- 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list