Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
211c9f7b
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看板
提交
211c9f7b
编写于
6月 07, 2011
作者:
M
Minoru Usui
提交者:
Eric Blake
6月 14, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
virNodeGetCPUTime: Implement public API
Signed-off-by:
N
Minoru Usui
<
usui@mxm.nes.nec.co.jp
>
上级
85a44c6e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
94 addition
and
5 deletion
+94
-5
src/libvirt.c
src/libvirt.c
+94
-5
未找到文件。
src/libvirt.c
浏览文件 @
211c9f7b
...
@@ -3008,16 +3008,15 @@ error:
...
@@ -3008,16 +3008,15 @@ error:
* array, i.e. (sizeof(@virTypedParameter) * @nparams) bytes and call the API
* array, i.e. (sizeof(@virTypedParameter) * @nparams) bytes and call the API
* again.
* again.
*
*
* Here is
the
sample code snippet:
* Here is
a
sample code snippet:
*
*
* if ((virDomainGetMemoryParameters(dom, NULL, &nparams, 0) == 0) &&
* if ((virDomainGetMemoryParameters(dom, NULL, &nparams, 0) == 0) &&
* (nparams != 0)) {
* (nparams != 0)) {
* params = vshMalloc(ctl, sizeof(*params) * nparams);
* if ((params = malloc(sizeof(*params) * nparams)) == NULL)
* goto error;
* memset(params, 0, sizeof(*params) * nparams);
* memset(params, 0, sizeof(*params) * nparams);
* if (virDomainGetMemoryParameters(dom, params, &nparams, 0)) {
* if (virDomainGetMemoryParameters(dom, params, &nparams, 0))
* vshError(ctl, "%s", _("Unable to get memory parameters"));
* goto error;
* goto error;
* }
* }
* }
*
*
* This function requires privileged access to the hypervisor. This function
* This function requires privileged access to the hypervisor. This function
...
@@ -5285,6 +5284,96 @@ error:
...
@@ -5285,6 +5284,96 @@ error:
return
NULL
;
return
NULL
;
}
}
/**
* virNodeGetCPUStats:
* @conn: pointer to the hypervisor connection.
* @cpuNum: number of node cpu. (VIR_CPU_STATS_ALL_CPUS means total cpu
* statistics)
* @params: pointer to node cpu time parameter objects
* @nparams: number of node cpu time parameter (this value should be same or
* less than the number of parameters supported)
* @flags: currently unused, for future extension. always pass 0.
*
* This function provides individual cpu statistics of the node.
* If you want to get total cpu statistics of the node, you must specify
* VIR_CPU_STATS_ALL_CPUS to @cpuNum.
* The @params array will be filled with the values equal to the number of
* parameters suggested by @nparams
*
* As the value of @nparams is dynamic, call the API setting @nparams to 0 and
* @params as NULL, the API returns the number of parameters supported by the
* HV by updating @nparams on SUCCESS. The caller should then allocate @params
* array, i.e. (sizeof(@virCPUStats) * @nparams) bytes and call
* the API again.
*
* Here is a sample code snippet:
*
* if ((virNodeGetCPUStats(conn, cpuNum, NULL, &nparams, 0) == 0) &&
* (nparams != 0)) {
* if ((params = malloc(sizeof(virCPUStats) * nparams)) == NULL)
* goto error;
* memset(params, 0, sizeof(virCPUStats) * nparams);
* if (virNodeGetCPUStats(conn, cpuNum, params, &nparams, 0))
* goto error;
* }
*
* This function doesn't require privileged access to the hypervisor.
* This function expects the caller to allocate the @params.
*
* CPU time Statistics:
*
* VIR_NODE_CPU_STATS_KERNEL:
* The cumulative CPU time which spends by kernel,
* when the node booting up.(nanoseconds)
* VIR_NODE_CPU_STATS_USER:
* The cumulative CPU time which spends by user processes,
* when the node booting up.(nanoseconds)
* VIR_NODE_CPU_STATS_IDLE:
* The cumulative idle CPU time, when the node booting up.(nanoseconds)
* VIR_NODE_CPU_STATS_IOWAIT:
* The cumulative I/O wait CPU time, when the node booting up.(nanoseconds)
* VIR_NODE_CPU_STATS_UTILIZATION:
* The CPU utilization. The usage value is in percent and 100%
* represents all CPUs on the server.
*
* Returns -1 in case of error, 0 in case of success.
*/
int
virNodeGetCPUStats
(
virConnectPtr
conn
,
int
cpuNum
,
virCPUStatsPtr
params
,
int
*
nparams
,
unsigned
int
flags
)
{
VIR_DEBUG
(
"conn=%p, cpuNum=%d, params=%p, nparams=%d, flags=%u"
,
conn
,
cpuNum
,
params
,
nparams
?
*
nparams
:
-
1
,
flags
);
virResetLastError
();
if
(
!
VIR_IS_CONNECT
(
conn
))
{
virLibConnError
(
VIR_ERR_INVALID_CONN
,
__FUNCTION__
);
virDispatchError
(
NULL
);
return
-
1
;
}
if
((
nparams
==
NULL
)
||
(
*
nparams
<
0
)
||
((
cpuNum
<
0
)
&&
(
cpuNum
!=
VIR_CPU_STATS_ALL_CPUS
)))
{
virLibConnError
(
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
goto
error
;
}
if
(
conn
->
driver
->
nodeGetCPUStats
)
{
int
ret
;
ret
=
conn
->
driver
->
nodeGetCPUStats
(
conn
,
cpuNum
,
params
,
nparams
,
flags
);
if
(
ret
<
0
)
goto
error
;
return
ret
;
}
virLibConnError
(
VIR_ERR_NO_SUPPORT
,
__FUNCTION__
);
error:
virDispatchError
(
conn
);
return
-
1
;
}
/**
/**
* virNodeGetFreeMemory:
* virNodeGetFreeMemory:
* @conn: pointer to the hypervisor connection
* @conn: pointer to the hypervisor connection
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录