From nobody Tue Apr 30 05:07:53 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; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1542680009626238.09519358880982; Mon, 19 Nov 2018 18:13:29 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D685389AE7; Tue, 20 Nov 2018 02:13:25 +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 0E11068876; Tue, 20 Nov 2018 02:13:25 +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 7B47F181B9E3; Tue, 20 Nov 2018 02:13:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAK2CZxF009758 for ; Mon, 19 Nov 2018 21:12:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id E238010694FE; Tue, 20 Nov 2018 02:12:35 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9282B1062222; Tue, 20 Nov 2018 02:12:30 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7F5CCC050009; Tue, 20 Nov 2018 02:12:29 +0000 (UTC) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2018 18:12:29 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by fmsmga005.fm.intel.com with ESMTP; 19 Nov 2018 18:12:27 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,255,1539673200"; d="scan'208";a="281370523" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Tue, 20 Nov 2018 10:10:39 +0800 Message-Id: <1542679839-14292-1-git-send-email-huaqiang.wang@intel.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 20 Nov 2018 02:12:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 20 Nov 2018 02:12:29 +0000 (UTC) for IP:'192.55.52.120' DOMAIN:'mga04.intel.com' HELO:'mga04.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 192.55.52.120 mga04.intel.com 192.55.52.120 mga04.intel.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCH] util: Fix a bug in virResctrlMonitorGetStats 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 20 Nov 2018 02:13:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The path argument of virFileIsDir should be a full name of file, pathname and filename. Fixed it by passing the full path name to virFileIsDir. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/util/virresctrl.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 7aeca9d..e0ad460 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2665,6 +2665,7 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monito= r, int ret =3D -1; DIR *dirp =3D NULL; char *datapath =3D NULL; + char *filepath =3D NULL; struct dirent *ent =3D NULL; virResctrlMonitorStatsPtr stat =3D NULL; =20 @@ -2684,13 +2685,18 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr moni= tor, while (virDirRead(dirp, &ent, datapath) > 0) { char *node_id =3D NULL; =20 + VIR_FREE(filepath); + /* Looking for directory that contains resource utilization * information file. The directory name is arranged in format * "mon__". For example, "mon_L3_00" and * "mon_L3_01" are two target directories for a two nodes system * with resource utilization data file for each node respectively. */ - if (!virFileIsDir(ent->d_name)) + if (virAsprintf(&filepath, "%s/%s", datapath, ent->d_name) < 0); + goto cleanup; + + if (!virFileIsDir(filepath)) continue; =20 /* Looking for directory has a prefix 'mon_L' */ @@ -2734,6 +2740,7 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monito= r, ret =3D 0; cleanup: VIR_FREE(datapath); + VIR_FREE(filepath); VIR_FREE(stat); VIR_DIR_CLOSE(dirp); return ret; --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list