Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
65158899
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看板
提交
65158899
编写于
2月 14, 2014
作者:
T
Thorsten Behrens
提交者:
Michal Privoznik
2月 20, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make qemuGetDomainTotalCPUStats a virCgroup function.
To reuse this from other drivers, like lxc.
上级
192604dd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
61 addition
and
52 deletion
+61
-52
src/libvirt_private.syms
src/libvirt_private.syms
+1
-0
src/qemu/qemu_driver.c
src/qemu/qemu_driver.c
+2
-52
src/util/vircgroup.c
src/util/vircgroup.c
+53
-0
src/util/vircgroup.h
src/util/vircgroup.h
+5
-0
未找到文件。
src/libvirt_private.syms
浏览文件 @
65158899
...
...
@@ -1025,6 +1025,7 @@ virCgroupGetCpuCfsQuota;
virCgroupGetCpusetCpus;
virCgroupGetCpusetMems;
virCgroupGetCpuShares;
virCgroupGetDomainTotalCpuStats;
virCgroupGetFreezerState;
virCgroupGetMemoryHardLimit;
virCgroupGetMemorySoftLimit;
...
...
src/qemu/qemu_driver.c
浏览文件 @
65158899
...
...
@@ -106,7 +106,6 @@
#define QEMU_NB_NUMA_PARAM 2
#define QEMU_NB_TOTAL_CPU_STAT_PARAM 3
#define QEMU_NB_PER_CPU_STAT_PARAM 2
#define QEMU_SCHED_MIN_PERIOD 1000LL
...
...
@@ -15903,56 +15902,6 @@ cleanup:
return ret;
}
/* qemuDomainGetCPUStats() with start_cpu == -1 */
static int
qemuDomainGetTotalcpuStats(virDomainObjPtr vm,
virTypedParameterPtr params,
int nparams)
{
unsigned long long cpu_time;
int ret;
qemuDomainObjPrivatePtr priv = vm->privateData;
if (nparams == 0) /* return supported number of params */
return QEMU_NB_TOTAL_CPU_STAT_PARAM;
/* entry 0 is cputime */
ret = virCgroupGetCpuacctUsage(priv->cgroup, &cpu_time);
if (ret < 0) {
virReportSystemError(-ret, "%s", _("unable to get cpu account"));
return -1;
}
if (virTypedParameterAssign(¶ms[0], VIR_DOMAIN_CPU_STATS_CPUTIME,
VIR_TYPED_PARAM_ULLONG, cpu_time) < 0)
return -1;
if (nparams > 1) {
unsigned long long user;
unsigned long long sys;
ret = virCgroupGetCpuacctStat(priv->cgroup, &user, &sys);
if (ret < 0) {
virReportSystemError(-ret, "%s", _("unable to get cpu account"));
return -1;
}
if (virTypedParameterAssign(¶ms[1],
VIR_DOMAIN_CPU_STATS_USERTIME,
VIR_TYPED_PARAM_ULLONG, user) < 0)
return -1;
if (nparams > 2 &&
virTypedParameterAssign(¶ms[2],
VIR_DOMAIN_CPU_STATS_SYSTEMTIME,
VIR_TYPED_PARAM_ULLONG, sys) < 0)
return -1;
if (nparams > QEMU_NB_TOTAL_CPU_STAT_PARAM)
nparams = QEMU_NB_TOTAL_CPU_STAT_PARAM;
}
return nparams;
}
/* This function gets the sums of cpu time consumed by all vcpus.
* For example, if there are 4 physical cpus, and 2 vcpus in a domain,
* then for each vcpu, the cpuacct.usage_percpu looks like this:
...
...
@@ -16150,7 +16099,8 @@ qemuDomainGetCPUStats(virDomainPtr domain,
}
if (start_cpu == -1)
ret = qemuDomainGetTotalcpuStats(vm, params, nparams);
ret = virCgroupGetDomainTotalCpuStats(priv->cgroup,
params, nparams);
else
ret = qemuDomainGetPercpuStats(vm, params, nparams,
start_cpu, ncpus);
...
...
src/util/vircgroup.c
浏览文件 @
65158899
...
...
@@ -51,11 +51,14 @@
#include "virhashcode.h"
#include "virstring.h"
#include "virsystemd.h"
#include "virtypedparam.h"
#define CGROUP_MAX_VAL 512
#define VIR_FROM_THIS VIR_FROM_CGROUP
#define CGROUP_NB_TOTAL_CPU_STAT_PARAM 3
#if defined(__linux__) && defined(HAVE_GETMNTENT_R) && \
defined(_DIRENT_HAVE_D_TYPE) && defined(_SC_CLK_TCK)
# define VIR_CGROUP_SUPPORTED
...
...
@@ -2821,6 +2824,56 @@ virCgroupDenyDevicePath(virCgroupPtr group, const char *path, int perms)
}
int
virCgroupGetDomainTotalCpuStats
(
virCgroupPtr
group
,
virTypedParameterPtr
params
,
int
nparams
)
{
unsigned
long
long
cpu_time
;
int
ret
;
if
(
nparams
==
0
)
/* return supported number of params */
return
CGROUP_NB_TOTAL_CPU_STAT_PARAM
;
/* entry 0 is cputime */
ret
=
virCgroupGetCpuacctUsage
(
group
,
&
cpu_time
);
if
(
ret
<
0
)
{
virReportSystemError
(
-
ret
,
"%s"
,
_
(
"unable to get cpu account"
));
return
-
1
;
}
if
(
virTypedParameterAssign
(
&
params
[
0
],
VIR_DOMAIN_CPU_STATS_CPUTIME
,
VIR_TYPED_PARAM_ULLONG
,
cpu_time
)
<
0
)
return
-
1
;
if
(
nparams
>
1
)
{
unsigned
long
long
user
;
unsigned
long
long
sys
;
ret
=
virCgroupGetCpuacctStat
(
group
,
&
user
,
&
sys
);
if
(
ret
<
0
)
{
virReportSystemError
(
-
ret
,
"%s"
,
_
(
"unable to get cpu account"
));
return
-
1
;
}
if
(
virTypedParameterAssign
(
&
params
[
1
],
VIR_DOMAIN_CPU_STATS_USERTIME
,
VIR_TYPED_PARAM_ULLONG
,
user
)
<
0
)
return
-
1
;
if
(
nparams
>
2
&&
virTypedParameterAssign
(
&
params
[
2
],
VIR_DOMAIN_CPU_STATS_SYSTEMTIME
,
VIR_TYPED_PARAM_ULLONG
,
sys
)
<
0
)
return
-
1
;
if
(
nparams
>
CGROUP_NB_TOTAL_CPU_STAT_PARAM
)
nparams
=
CGROUP_NB_TOTAL_CPU_STAT_PARAM
;
}
return
nparams
;
}
int
virCgroupSetCpuShares
(
virCgroupPtr
group
,
unsigned
long
long
shares
)
{
...
...
src/util/vircgroup.h
浏览文件 @
65158899
...
...
@@ -201,6 +201,11 @@ int virCgroupDenyDevicePath(virCgroupPtr group,
const
char
*
path
,
int
perms
);
int
virCgroupGetDomainTotalCpuStats
(
virCgroupPtr
group
,
virTypedParameterPtr
params
,
int
nparams
);
int
virCgroupSetCpuShares
(
virCgroupPtr
group
,
unsigned
long
long
shares
);
int
virCgroupGetCpuShares
(
virCgroupPtr
group
,
unsigned
long
long
*
shares
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录