Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
39e5173a
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看板
提交
39e5173a
编写于
1月 16, 2013
作者:
J
Jiri Denemark
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
virsh: Use virTypedParams* APIs in blkiotune
上级
a8fca0da
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
41 deletion
+23
-41
tools/virsh-domain.c
tools/virsh-domain.c
+23
-41
未找到文件。
tools/virsh-domain.c
浏览文件 @
39e5173a
...
@@ -1228,9 +1228,10 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
...
@@ -1228,9 +1228,10 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
const
char
*
device_weight
=
NULL
;
const
char
*
device_weight
=
NULL
;
int
weight
=
0
;
int
weight
=
0
;
int
nparams
=
0
;
int
nparams
=
0
;
int
maxparams
=
0
;
int
rv
=
0
;
int
rv
=
0
;
unsigned
int
i
=
0
;
unsigned
int
i
=
0
;
virTypedParameterPtr
params
=
NULL
,
temp
=
NULL
;
virTypedParameterPtr
params
=
NULL
;
bool
ret
=
false
;
bool
ret
=
false
;
unsigned
int
flags
=
0
;
unsigned
int
flags
=
0
;
bool
current
=
vshCommandOptBool
(
cmd
,
"current"
);
bool
current
=
vshCommandOptBool
(
cmd
,
"current"
);
...
@@ -1254,27 +1255,27 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
...
@@ -1254,27 +1255,27 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
return
false
;
return
false
;
if
((
rv
=
vshCommandOptInt
(
cmd
,
"weight"
,
&
weight
))
<
0
)
{
if
((
rv
=
vshCommandOptInt
(
cmd
,
"weight"
,
&
weight
))
<
0
)
{
vshError
(
ctl
,
"%s"
,
vshError
(
ctl
,
"%s"
,
_
(
"Unable to parse integer parameter"
));
_
(
"Unable to parse integer parameter"
));
goto
cleanup
;
goto
cleanup
;
}
}
else
if
(
rv
>
0
)
{
if
(
rv
>
0
)
{
nparams
++
;
if
(
weight
<=
0
)
{
if
(
weight
<=
0
)
{
vshError
(
ctl
,
_
(
"Invalid value of %d for I/O weight"
),
weight
);
vshError
(
ctl
,
_
(
"Invalid value of %d for I/O weight"
),
weight
);
goto
cleanup
;
goto
cleanup
;
}
}
if
(
virTypedParamsAddUInt
(
&
params
,
&
nparams
,
&
maxparams
,
VIR_DOMAIN_BLKIO_WEIGHT
,
weight
)
<
0
)
goto
save_error
;
}
}
rv
=
vshCommandOptString
(
cmd
,
"device-weights"
,
&
device_weight
);
rv
=
vshCommandOptString
(
cmd
,
"device-weights"
,
&
device_weight
);
if
(
rv
<
0
)
{
if
(
rv
<
0
)
{
vshError
(
ctl
,
"%s"
,
vshError
(
ctl
,
"%s"
,
_
(
"Unable to parse string parameter"
));
_
(
"Unable to parse string parameter"
));
goto
cleanup
;
goto
cleanup
;
}
}
else
if
(
rv
>
0
)
{
if
(
rv
>
0
)
{
if
(
virTypedParamsAddString
(
&
params
,
&
nparams
,
&
maxparams
,
nparams
++
;
VIR_DOMAIN_BLKIO_DEVICE_WEIGHT
,
device_weight
)
<
0
)
goto
save_error
;
}
}
if
(
nparams
==
0
)
{
if
(
nparams
==
0
)
{
...
@@ -1305,41 +1306,22 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
...
@@ -1305,41 +1306,22 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
}
}
}
else
{
}
else
{
/* set the blkio parameters */
/* set the blkio parameters */
params
=
vshCalloc
(
ctl
,
nparams
,
sizeof
(
*
params
));
if
(
virDomainSetBlkioParameters
(
dom
,
params
,
nparams
,
flags
)
<
0
)
goto
error
;
for
(
i
=
0
;
i
<
nparams
;
i
++
)
{
temp
=
&
params
[
i
];
temp
->
type
=
VIR_TYPED_PARAM_UINT
;
if
(
weight
)
{
temp
->
value
.
ui
=
weight
;
if
(
!
virStrcpy
(
temp
->
field
,
VIR_DOMAIN_BLKIO_WEIGHT
,
sizeof
(
temp
->
field
)))
goto
cleanup
;
weight
=
0
;
}
else
if
(
device_weight
)
{
temp
->
value
.
s
=
vshStrdup
(
ctl
,
device_weight
);
temp
->
type
=
VIR_TYPED_PARAM_STRING
;
if
(
!
virStrcpy
(
temp
->
field
,
VIR_DOMAIN_BLKIO_DEVICE_WEIGHT
,
sizeof
(
temp
->
field
)))
goto
cleanup
;
device_weight
=
NULL
;
}
}
if
(
virDomainSetBlkioParameters
(
dom
,
params
,
nparams
,
flags
)
<
0
)
{
vshError
(
ctl
,
"%s"
,
_
(
"Unable to change blkio parameters"
));
goto
cleanup
;
}
}
}
ret
=
true
;
ret
=
true
;
cleanup:
cleanup:
virTypedParameterArrayClear
(
params
,
nparams
);
virTypedParamsFree
(
params
,
nparams
);
VIR_FREE
(
params
);
virDomainFree
(
dom
);
virDomainFree
(
dom
);
return
ret
;
return
ret
;
save_error:
vshSaveLibvirtError
();
error:
vshError
(
ctl
,
"%s"
,
_
(
"Unable to change blkio parameters"
));
goto
cleanup
;
}
}
typedef
enum
{
typedef
enum
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录