Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
1aeb3d9e
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1aeb3d9e
编写于
3月 27, 2012
作者:
G
Guannan Ren
提交者:
Eric Blake
3月 28, 2012
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
python: make python APIs use these helper functions
*setPyVirTypedParameter *libvirt_virDomainGetCPUStats
上级
384ebd3f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
71 deletion
+24
-71
python/libvirt-override-api.xml
python/libvirt-override-api.xml
+2
-2
python/libvirt-override.c
python/libvirt-override.c
+22
-69
未找到文件。
python/libvirt-override-api.xml
浏览文件 @
1aeb3d9e
...
...
@@ -151,11 +151,11 @@
</function>
<function
name=
'virDomainGetCPUStats'
file=
'python'
>
<info>
Extracts CPU statistics for a running domain. On success it will
return a list of data of dictionary type. If boolean total is False, the
return a list of data of dictionary type. If boolean total is False
or 0
, the
first element of the list refers to CPU0 on the host, second element is
CPU1, and so on. The format of data struct is as follows:
[{cpu_time:xxx}, {cpu_time:xxx}, ...]
If it is True, it returns total domain CPU statistics in the format of
If it is True
or 1
, it returns total domain CPU statistics in the format of
[{cpu_time:xxx, user_time:xxx, system_time:xxx}]
</info>
<return
type=
'str *'
info=
'returns a list of dictionary in case of success, None in case of error'
/>
<arg
name=
'domain'
type=
'virDomainPtr'
info=
'pointer to domain object'
/>
...
...
python/libvirt-override.c
浏览文件 @
1aeb3d9e
...
...
@@ -194,76 +194,38 @@ setPyVirTypedParameter(PyObject *info,
switch
(
params
[
i
].
type
)
{
case
VIR_TYPED_PARAM_INT
:
{
long
long_val
=
PyInt_AsLong
(
value
);
if
((
long_val
==
-
1
)
&&
PyErr_Occurred
())
goto
cleanup
;
if
((
int
)
long_val
==
long_val
)
{
temp
->
value
.
i
=
long_val
;
}
else
{
PyErr_Format
(
PyExc_ValueError
,
"The value of "
"attribute
\"
%s
\"
is out of int range"
,
keystr
);
if
(
libvirt_intUnwrap
(
value
,
&
temp
->
value
.
i
)
<
0
)
goto
cleanup
;
}
}
break
;
break
;
case
VIR_TYPED_PARAM_UINT
:
{
long
long_val
=
PyInt_AsLong
(
value
);
if
((
long_val
==
-
1
)
&&
PyErr_Occurred
())
if
(
libvirt_uintUnwrap
(
value
,
&
temp
->
value
.
ui
)
<
0
)
goto
cleanup
;
if
((
unsigned
int
)
long_val
==
long_val
)
{
temp
->
value
.
ui
=
long_val
;
}
else
{
PyErr_Format
(
PyExc_ValueError
,
"The value of "
"attribute
\"
%s
\"
is out of int range"
,
keystr
);
goto
cleanup
;
}
}
break
;
break
;
case
VIR_TYPED_PARAM_LLONG
:
{
long
long
llong_val
=
PyLong_AsLongLong
(
value
);
if
((
llong_val
==
-
1
)
&&
PyErr_Occurred
())
if
(
libvirt_longlongUnwrap
(
value
,
&
temp
->
value
.
l
)
<
0
)
goto
cleanup
;
temp
->
value
.
l
=
llong_val
;
}
break
;
break
;
case
VIR_TYPED_PARAM_ULLONG
:
{
unsigned
long
long
ullong_val
=
PyLong_AsUnsignedLongLong
(
value
);
if
((
ullong_val
==
-
1
)
&&
PyErr_Occurred
())
if
(
libvirt_ulonglongUnwrap
(
value
,
&
temp
->
value
.
ul
)
<
0
)
goto
cleanup
;
temp
->
value
.
ul
=
ullong_val
;
}
break
;
break
;
case
VIR_TYPED_PARAM_DOUBLE
:
{
double
double_val
=
PyFloat_AsDouble
(
value
);
if
((
double_val
==
-
1
)
&&
PyErr_Occurred
())
if
(
libvirt_doubleUnwrap
(
value
,
&
temp
->
value
.
d
)
<
0
)
goto
cleanup
;
temp
->
value
.
d
=
double_val
;
}
break
;
break
;
case
VIR_TYPED_PARAM_BOOLEAN
:
{
/* Hack - Python's definition of Py_True breaks strict
* aliasing rules, so can't directly compare
*/
if
(
PyBool_Check
(
value
))
{
PyObject
*
hacktrue
=
PyBool_FromLong
(
1
);
temp
->
value
.
b
=
hacktrue
==
value
?
1
:
0
;
Py_DECREF
(
hacktrue
);
}
else
{
PyErr_Format
(
PyExc_TypeError
,
"The value type of "
"attribute
\"
%s
\"
must be bool"
,
keystr
);
bool
b
;
if
(
libvirt_boolUnwrap
(
value
,
&
b
)
<
0
)
goto
cleanup
;
}
temp
->
value
.
b
=
b
;
break
;
}
break
;
case
VIR_TYPED_PARAM_STRING
:
{
char
*
string_val
=
PyString_AsString
(
value
);
...
...
@@ -388,7 +350,8 @@ libvirt_virDomainGetCPUStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
int
ncpus
=
-
1
,
start_cpu
=
0
;
int
sumparams
=
0
,
nparams
=
-
1
;
int
i
,
i_retval
;
unsigned
int
flags
,
totalflag
;
unsigned
int
flags
;
bool
totalflag
;
virTypedParameterPtr
params
=
NULL
,
cpuparams
;
if
(
!
PyArg_ParseTuple
(
args
,
(
char
*
)
"OOi:virDomainGetCPUStats"
,
...
...
@@ -396,18 +359,8 @@ libvirt_virDomainGetCPUStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
return
NULL
;
domain
=
(
virDomainPtr
)
PyvirDomain_Get
(
pyobj_domain
);
if
(
!
PyBool_Check
(
totalbool
))
{
PyErr_Format
(
PyExc_TypeError
,
"The
\"
total
\"
attribute must be bool"
);
if
(
libvirt_boolUnwrap
(
totalbool
,
&
totalflag
)
<
0
)
return
NULL
;
}
else
{
/* Hack - Python's definition of Py_True breaks strict
* aliasing rules, so can't directly compare
*/
PyObject
*
hacktrue
=
PyBool_FromLong
(
1
);
totalflag
=
hacktrue
==
totalbool
?
1
:
0
;
Py_DECREF
(
hacktrue
);
}
if
((
ret
=
PyList_New
(
0
))
==
NULL
)
return
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录