提交 4e8b37d4 编写于 作者: W Wang Huaqiang 提交者: John Ferlan

util: Fix a bug in virResctrlMonitorGetStats

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: NWang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 88a109a1
...@@ -2665,6 +2665,7 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monitor, ...@@ -2665,6 +2665,7 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monitor,
int ret = -1; int ret = -1;
DIR *dirp = NULL; DIR *dirp = NULL;
char *datapath = NULL; char *datapath = NULL;
char *filepath = NULL;
struct dirent *ent = NULL; struct dirent *ent = NULL;
virResctrlMonitorStatsPtr stat = NULL; virResctrlMonitorStatsPtr stat = NULL;
...@@ -2684,13 +2685,18 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monitor, ...@@ -2684,13 +2685,18 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monitor,
while (virDirRead(dirp, &ent, datapath) > 0) { while (virDirRead(dirp, &ent, datapath) > 0) {
char *node_id = NULL; char *node_id = NULL;
VIR_FREE(filepath);
/* Looking for directory that contains resource utilization /* Looking for directory that contains resource utilization
* information file. The directory name is arranged in format * information file. The directory name is arranged in format
* "mon_<node_name>_<node_id>". For example, "mon_L3_00" and * "mon_<node_name>_<node_id>". For example, "mon_L3_00" and
* "mon_L3_01" are two target directories for a two nodes system * "mon_L3_01" are two target directories for a two nodes system
* with resource utilization data file for each node respectively. * 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; continue;
/* Looking for directory has a prefix 'mon_L' */ /* Looking for directory has a prefix 'mon_L' */
...@@ -2734,6 +2740,7 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monitor, ...@@ -2734,6 +2740,7 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monitor,
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(datapath); VIR_FREE(datapath);
VIR_FREE(filepath);
VIR_FREE(stat); VIR_FREE(stat);
VIR_DIR_CLOSE(dirp); VIR_DIR_CLOSE(dirp);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册