Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
6528b704
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,发现更多精彩内容 >>
提交
6528b704
编写于
4月 08, 2013
作者:
J
John Ferlan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add error handling to optional arguments in cmdCPUStats
上级
ad86ebb2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
8 deletion
+27
-8
tools/virsh-domain.c
tools/virsh-domain.c
+27
-8
未找到文件。
tools/virsh-domain.c
浏览文件 @
6528b704
...
@@ -6140,19 +6140,39 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
...
@@ -6140,19 +6140,39 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
{
{
virDomainPtr
dom
;
virDomainPtr
dom
;
virTypedParameterPtr
params
=
NULL
;
virTypedParameterPtr
params
=
NULL
;
int
i
,
j
,
pos
,
max_id
,
cpu
=
-
1
,
show_count
=
-
1
,
nparams
=
0
;
int
i
,
j
,
pos
,
max_id
,
cpu
=
0
,
show_count
=
-
1
,
nparams
=
0
;
bool
show_total
=
false
,
show_per_cpu
=
false
;
bool
show_total
=
false
,
show_per_cpu
=
false
;
unsigned
int
flags
=
0
;
unsigned
int
flags
=
0
;
bool
ret
=
false
;
bool
ret
=
false
;
int
rv
=
0
;
if
(
!
(
dom
=
vshCommandOptDomain
(
ctl
,
cmd
,
NULL
)))
if
(
!
(
dom
=
vshCommandOptDomain
(
ctl
,
cmd
,
NULL
)))
return
false
;
return
false
;
show_total
=
vshCommandOptBool
(
cmd
,
"total"
);
show_total
=
vshCommandOptBool
(
cmd
,
"total"
);
if
(
vshCommandOptInt
(
cmd
,
"start"
,
&
cpu
)
>
0
)
if
((
rv
=
vshCommandOptInt
(
cmd
,
"start"
,
&
cpu
))
<
0
)
{
vshError
(
ctl
,
"%s"
,
_
(
"Unable to parse integer parameter for start"
));
goto
cleanup
;
}
else
if
(
rv
>
0
)
{
if
(
cpu
<
0
)
{
vshError
(
ctl
,
"%s"
,
_
(
"Invalid value for start CPU"
));
goto
cleanup
;
}
show_per_cpu
=
true
;
show_per_cpu
=
true
;
if
(
vshCommandOptInt
(
cmd
,
"count"
,
&
show_count
)
>
0
)
}
if
((
rv
=
vshCommandOptInt
(
cmd
,
"count"
,
&
show_count
))
<
0
)
{
vshError
(
ctl
,
"%s"
,
_
(
"Unable to parse integer parameter for CPUs to show"
));
goto
cleanup
;
}
else
if
(
rv
>
0
)
{
if
(
show_count
<
0
)
{
vshError
(
ctl
,
"%s"
,
_
(
"Invalid value for number of CPUs to show"
));
goto
cleanup
;
}
show_per_cpu
=
true
;
show_per_cpu
=
true
;
}
/* default show per_cpu and total */
/* default show per_cpu and total */
if
(
!
show_total
&&
!
show_per_cpu
)
{
if
(
!
show_total
&&
!
show_per_cpu
)
{
...
@@ -6163,15 +6183,14 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
...
@@ -6163,15 +6183,14 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
if
(
!
show_per_cpu
)
/* show total stats only */
if
(
!
show_per_cpu
)
/* show total stats only */
goto
do_show_total
;
goto
do_show_total
;
/* check cpu, show_count, and ignore wrong argument */
if
(
cpu
<
0
)
cpu
=
0
;
/* get number of cpus on the node */
/* get number of cpus on the node */
if
((
max_id
=
virDomainGetCPUStats
(
dom
,
NULL
,
0
,
0
,
0
,
flags
))
<
0
)
if
((
max_id
=
virDomainGetCPUStats
(
dom
,
NULL
,
0
,
0
,
0
,
flags
))
<
0
)
goto
failed_stats
;
goto
failed_stats
;
if
(
show_count
<
0
||
show_count
>
max_id
)
if
(
show_count
<
0
||
show_count
>
max_id
)
{
if
(
show_count
>
max_id
)
vshPrint
(
ctl
,
_
(
"Only %d CPUs available to show
\n
"
),
max_id
);
show_count
=
max_id
;
show_count
=
max_id
;
}
/* get percpu information */
/* get percpu information */
if
((
nparams
=
virDomainGetCPUStats
(
dom
,
NULL
,
0
,
0
,
1
,
flags
))
<
0
)
if
((
nparams
=
virDomainGetCPUStats
(
dom
,
NULL
,
0
,
0
,
1
,
flags
))
<
0
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录