提交 3a1356d4 编写于 作者: B Bing Niu 提交者: John Ferlan

util: Refactor virResctrlGetInfo in virresctrl

Separate resctrl common information parts from CAT specific parts,
so that common information parts can be reused among different
resource allocation technologies.
Signed-off-by: NBing Niu <bing.niu@intel.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 f7c7f8ea
......@@ -318,9 +318,9 @@ virResctrlUnlock(int fd)
/* virResctrlInfo-related definitions */
static int
virResctrlGetInfo(virResctrlInfoPtr resctrl)
virResctrlGetCacheInfo(virResctrlInfoPtr resctrl,
DIR *dirp)
{
DIR *dirp = NULL;
char *endptr = NULL;
char *tmp_str = NULL;
int ret = -1;
......@@ -332,12 +332,6 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
virResctrlInfoPerLevelPtr i_level = NULL;
virResctrlInfoPerTypePtr i_type = NULL;
rv = virDirOpenIfExists(&dirp, SYSFS_RESCTRL_PATH "/info");
if (rv <= 0) {
ret = rv;
goto cleanup;
}
while ((rv = virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH "/info")) > 0) {
VIR_DEBUG("Parsing info type '%s'", ent->d_name);
if (ent->d_name[0] != 'L')
......@@ -443,12 +437,32 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
ret = 0;
cleanup:
VIR_DIR_CLOSE(dirp);
VIR_FREE(i_type);
return ret;
}
static int
virResctrlGetInfo(virResctrlInfoPtr resctrl)
{
DIR *dirp = NULL;
int ret = -1;
ret = virDirOpenIfExists(&dirp, SYSFS_RESCTRL_PATH "/info");
if (ret <= 0)
goto cleanup;
ret = virResctrlGetCacheInfo(resctrl, dirp);
if (ret < 0)
goto cleanup;
ret = 0;
cleanup:
VIR_DIR_CLOSE(dirp);
return ret;
}
virResctrlInfoPtr
virResctrlInfoNew(void)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册