Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
f6199295
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f6199295
编写于
1月 25, 2018
作者:
M
Martin Kletzander
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
util: Add helpers for getting resctrl group allocs
Signed-off-by:
N
Martin Kletzander
<
mkletzan@redhat.com
>
上级
f46d6e22
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
54 addition
and
27 deletion
+54
-27
src/util/virresctrl.c
src/util/virresctrl.c
+54
-27
未找到文件。
src/util/virresctrl.c
浏览文件 @
f6199295
...
...
@@ -1041,6 +1041,55 @@ virResctrlAllocParse(virResctrlInfoPtr resctrl,
}
static
int
virResctrlAllocGetGroup
(
virResctrlInfoPtr
resctrl
,
const
char
*
groupname
,
virResctrlAllocPtr
*
alloc
)
{
char
*
schemata
=
NULL
;
int
rv
=
virFileReadValueString
(
&
schemata
,
SYSFS_RESCTRL_PATH
"/%s/schemata"
,
groupname
);
*
alloc
=
NULL
;
if
(
rv
<
0
)
return
rv
;
*
alloc
=
virResctrlAllocNew
();
if
(
!*
alloc
)
goto
error
;
if
(
virResctrlAllocParse
(
resctrl
,
*
alloc
,
schemata
)
<
0
)
goto
error
;
VIR_FREE
(
schemata
);
return
0
;
error:
VIR_FREE
(
schemata
);
virObjectUnref
(
*
alloc
);
*
alloc
=
NULL
;
return
-
1
;
}
static
virResctrlAllocPtr
virResctrlAllocGetDefault
(
virResctrlInfoPtr
resctrl
)
{
virResctrlAllocPtr
ret
=
NULL
;
int
rv
=
virResctrlAllocGetGroup
(
resctrl
,
"."
,
&
ret
);
if
(
rv
==
-
2
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"Could not read schemata file for the default group"
));
}
return
ret
;
}
static
void
virResctrlAllocSubtractPerType
(
virResctrlAllocPerTypePtr
dst
,
virResctrlAllocPerTypePtr
src
)
...
...
@@ -1141,7 +1190,6 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
virResctrlAllocPtr
alloc
=
NULL
;
struct
dirent
*
ent
=
NULL
;
DIR
*
dirp
=
NULL
;
char
*
schemata
=
NULL
;
int
rv
=
-
1
;
if
(
virResctrlInfoIsEmpty
(
resctrl
))
{
...
...
@@ -1154,22 +1202,12 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
if
(
!
ret
)
return
NULL
;
if
(
virFileReadValueString
(
&
schemata
,
SYSFS_RESCTRL_PATH
"/schemata"
)
<
0
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"Could not read schemata file for the default group"
));
goto
error
;
}
alloc
=
virResctrlAllocNew
();
alloc
=
virResctrlAllocGetDefault
(
resctrl
);
if
(
!
alloc
)
goto
error
;
if
(
virResctrlAllocParse
(
resctrl
,
alloc
,
schemata
)
<
0
)
goto
error
;
virResctrlAllocSubtract
(
ret
,
alloc
);
virObjectUnref
(
alloc
);
if
(
virDirOpen
(
&
dirp
,
SYSFS_RESCTRL_PATH
)
<
0
)
goto
error
;
...
...
@@ -1178,11 +1216,7 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
if
(
STREQ
(
ent
->
d_name
,
"info"
))
continue
;
VIR_FREE
(
schemata
);
rv
=
virFileReadValueString
(
&
schemata
,
SYSFS_RESCTRL_PATH
"/%s/schemata"
,
ent
->
d_name
);
rv
=
virResctrlAllocGetGroup
(
resctrl
,
ent
->
d_name
,
&
alloc
);
if
(
rv
==
-
2
)
continue
;
...
...
@@ -1193,15 +1227,9 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
goto
error
;
}
virObjectUnref
(
alloc
);
alloc
=
virResctrlAllocNew
();
if
(
!
alloc
)
goto
error
;
if
(
virResctrlAllocParse
(
resctrl
,
alloc
,
schemata
)
<
0
)
goto
error
;
virResctrlAllocSubtract
(
ret
,
alloc
);
virObjectUnref
(
alloc
);
alloc
=
NULL
;
}
if
(
rv
<
0
)
goto
error
;
...
...
@@ -1209,7 +1237,6 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
cleanup:
virObjectUnref
(
alloc
);
VIR_DIR_CLOSE
(
dirp
);
VIR_FREE
(
schemata
);
return
ret
;
error:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录