Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
6c5d4e7c
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看板
提交
6c5d4e7c
编写于
7月 09, 2009
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use enums for cgroup controller types / labels
上级
5320ce02
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
17 deletion
+29
-17
src/cgroup.c
src/cgroup.c
+29
-17
未找到文件。
src/cgroup.c
浏览文件 @
6c5d4e7c
...
...
@@ -31,15 +31,21 @@
#define CGROUP_MAX_VAL 512
struct
virCgroup
{
char
*
path
;
enum
{
VIR_CGROUP_CONTROLLER_CPUACCT
,
VIR_CGROUP_CONTROLLER_MEMORY
,
VIR_CGROUP_CONTROLLER_DEVICES
,
VIR_CGROUP_CONTROLLER_CPUSET
,
VIR_CGROUP_CONTROLLER_LAST
};
const
char
*
supported_controllers
[]
=
{
"memory"
,
"devices"
,
"cpuacct"
,
NULL
VIR_ENUM_DECL
(
virCgroupController
);
VIR_ENUM_IMPL
(
virCgroupController
,
VIR_CGROUP_CONTROLLER_LAST
,
"cpuacct"
,
"memory"
,
"devices"
,
"cpuset"
);
struct
virCgroup
{
char
*
path
;
};
/**
...
...
@@ -107,8 +113,9 @@ int virCgroupHaveSupport(void)
virCgroupPtr
root
;
int
i
;
for
(
i
=
0
;
supported_controllers
[
i
]
!=
NULL
;
i
++
)
{
root
=
virCgroupGetMount
(
supported_controllers
[
i
]);
for
(
i
=
0
;
i
<
VIR_CGROUP_CONTROLLER_LAST
;
i
++
)
{
const
char
*
label
=
virCgroupControllerTypeToString
(
i
);
root
=
virCgroupGetMount
(
label
);
if
(
root
==
NULL
)
return
-
1
;
virCgroupFree
(
&
root
);
...
...
@@ -419,15 +426,16 @@ static int virCgroupMakeGroup(const char *name)
int
i
;
int
rc
=
0
;
for
(
i
=
0
;
supported_controllers
[
i
]
!=
NULL
;
i
++
)
{
for
(
i
=
0
;
i
<
VIR_CGROUP_CONTROLLER_LAST
;
i
++
)
{
const
char
*
label
=
virCgroupControllerTypeToString
(
i
);
char
*
path
=
NULL
;
virCgroupPtr
root
;
root
=
virCgroupGetMount
(
supported_controllers
[
i
]
);
root
=
virCgroupGetMount
(
label
);
if
(
root
==
NULL
)
continue
;
rc
=
virCgroupPathOfGroup
(
name
,
supported_controllers
[
i
]
,
&
path
);
rc
=
virCgroupPathOfGroup
(
name
,
label
,
&
path
);
if
(
rc
!=
0
)
{
virCgroupFree
(
&
root
);
break
;
...
...
@@ -521,6 +529,7 @@ static int virCgroupOpen(virCgroupPtr parent,
virCgroupPtr
*
newgroup
)
{
int
rc
=
0
;
const
char
*
label
=
virCgroupControllerTypeToString
(
0
);
char
*
grppath
=
NULL
;
bool
free_parent
=
(
parent
==
NULL
);
...
...
@@ -532,7 +541,7 @@ static int virCgroupOpen(virCgroupPtr parent,
virCgroupFree
(
&
parent
);
rc
=
virCgroupPathOfGroup
((
*
newgroup
)
->
path
,
supported_controllers
[
0
]
,
label
,
&
grppath
);
if
(
rc
!=
0
)
goto
err
;
...
...
@@ -594,9 +603,10 @@ int virCgroupRemove(virCgroupPtr group)
int
i
;
char
*
grppath
=
NULL
;
for
(
i
=
0
;
supported_controllers
[
i
]
!=
NULL
;
i
++
)
{
for
(
i
=
0
;
i
<
VIR_CGROUP_CONTROLLER_LAST
;
i
++
)
{
const
char
*
label
=
virCgroupControllerTypeToString
(
i
);
if
(
virCgroupPathOfGroup
(
group
->
path
,
supported_controllers
[
i
]
,
label
,
&
grppath
)
!=
0
)
continue
;
...
...
@@ -626,9 +636,11 @@ int virCgroupAddTask(virCgroupPtr group, pid_t pid)
char
*
taskpath
=
NULL
;
char
*
pidstr
=
NULL
;
for
(
i
=
0
;
supported_controllers
[
i
]
!=
NULL
;
i
++
)
{
for
(
i
=
0
;
i
<
VIR_CGROUP_CONTROLLER_LAST
;
i
++
)
{
const
char
*
label
=
virCgroupControllerTypeToString
(
i
);
rc
=
virCgroupPathOfGroup
(
group
->
path
,
supported_controllers
[
i
]
,
label
,
&
grppath
);
if
(
rc
!=
0
)
goto
done
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录